9

How do I set Windows Environment variables permanently, I see that the Windows environment variables are reset when you close the command window. I want to set them permanently so that I don't have to repeat the task every time I use CLI.

CleanX
  • 1,072
  • 3
  • 17
  • 24

2 Answers2

9

Right click on Computer, Advanced system settings, select Advanced tab and click Environment variables.

Note: once you modify the environment variables, you will have to restart your applications, including CLI.

user1764961
  • 653
  • 6
  • 21
  • For windows 8 users: Typing "Control Panel\All Control Panel Items\System" in the file explorer exposes the "Advance System Settings" link. – amalgamate Jan 06 '16 at 20:30
9

This can also be achieved from command prompt. The following example set a variable at user level:

SETX variable_name value

For machine level elevation is required:

SETX variable_name value /m
Alexei - check Codidact
  • 20,117
  • 15
  • 137
  • 145
  • 1
    If you use this for updating %PATH%, this will cut it down to 1024 chars and potentially delete every path behind that range. So take care when using. – Gary Klasen Jan 22 '21 at 07:40