Set PATH and Other Environment Variables in Windows 10

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

opentechguides.

com

Set PATH and other environment variables in


Windows 10
3-4 minutes

by Remy Pereira on 12th September 2016

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 both setx and set.

For example, you can set the PATH environment variable permanently (current and future
sessions) as below:

C:\>setx PATH "C:\myfolder;%PATH%"

SUCCESS: Specified value was saved.

C:\>set PATH=C:\myfolder;%PATH%

To view the current path, run:

C:\>echo %PATH%

Note:

1. 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 PATH "C:\myfolder;%PATH%"

SUCCESS: Specified value was saved.

2. 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:\myfolder;%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

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment

Add, Edit or Delete the environment variable you want to change, then reboot to activate the
changes.

You might also like