The Good Old Way
-
Press
Win+Eto open Windows Explorer. -
Right click on This PC in the left navigation panel or on the background, and click Properties.
-
Click Advanced system settings.
-
Click Environment Variables….
-
There are two groups of buttons. The above one is for current user, while the below one affects all users using the PC. Click New….
-
Enter the name and value of the new variable, and then click OK.
-
Restart shell (cmd, Git Bash, etc.) to make the changes effective. For VSCode embedded terminal, restarting VSCode is needed. On some old version Windows (such as Windows 7), restarting your computer is needed to make the changes effective.
The Quicker Way
-
Press
Win+X(or right click the Start button). -
Press
Y(or click System in the menu). -
Click Advanced system settings.
-
Click Environment Variables….
-
There are two groups of buttons. The above one is for current user, while the below one affects all users using the PC. Click New….
-
Enter the name and value of the new variable, and then click OK.
-
Restart shell (cmd, Git Bash, etc.) to make the changes effective. For VSCode embedded terminal, restarting VSCode is needed. On some old version Windows (such as Windows 7), restarting your computer is needed to make the changes effective.
The Nerdy Way
Press Win + R, enter rundll32.exe sysdm.cpl,EditEnvironmentVariables and press Enter.
Note that pressing Enter will run a task with user privilege, where you can only change settings for current user. Press Ctrl + Shift + Enter instead to run it as administrator.