In older windows systems you had to navigate to Advanced System Settings in Control Panel to view, edit or add environmental variables.
- Windows XP - Right-click My Computer, and then click Properties → Advanced → Environment variables → Choose New, Edit or Delete.
- Windows 7 - Click on Start → Computer → Properties → Advanced System Settings → Environment variables → Choose New, Edit or Delete.
In Windows 8 and 10, you can navigate to Advanced System Settings in a similar way.
- Windows 8 - Right click on bottom left corner to get Power User Task Menu → Select System → Advanced System Settings → Environment variables → Choose New, Edit or Delete.
- Windows 10 - Right click on Start Menu to get Power User Task Menu → Select System → Advanced System Settings → Environment variables → Choose New, Edit or Delete.
However, in Windows 10 you can directly get to the Environment Variables window using Search the web and Windows box next to the Start menu. Type environment variables in Windows Search box which gives you two options in search results:
- Edit the system environment variables
- Edit environment variables for your account.
Choose either option and you can add, edit or delete environment variables like PATH.
Set environment variables from command prompt
You can set environment variables from Windows Command Prompt using the set or setx command. The set command only sets the environment variable for the current session. The setx command sets it permanently, but not for the current session. If you want to set it for current as well as future sessions, use setx and set.
C:\>setx path1 "C:\Folder1;%path1%" SUCCESS: Specified value was saved. C:\>set path1=C:\Folder1;%path1%
- By default setx sets the variable in the local environment (Under HKEY_Current_User Registry key). If you want to set the system variable (Under HKEY_LOCAL_MACHINE registry key), use the flag /m. Start the command prompt as administrator on Windows 10, right click on Start menu and select Command Prompt(Admin).
C:\>setx /m path1 "C:\Folder1;%path1%" SUCCESS: Specified value was saved.
- The maximum value allowed for a enviroment variable is 1024 characters. So if your variable is long and you try to append to it with setx, you may get a truncated result.
C:\>setx path "C:\Folder1;%path%" WARNING: The data being saved is truncated to 1024 characters. SUCCESS: Specified value was saved.
Set environment variable by Registry edit
If your PATH variable is too long, then the best method would be to edit the registry.
For user environment variables, change the key
HKEY_CURRENT_USER\Environment. For System Environment variables change
Add, Edit or Delete the environment variable you want to change, then reboot to activate the changes.