set_the_path_variable_from_the_windows_command-line

Set the PATH Variable from the Windows Command-Line

Return to Windows Path, Windows Environment variables, Windows Path Environment variable

Windows Path variable

Set Windows path variable

Set the Windows path variable

Setting Windows path variable

Setting the Windows path variable

Set the Windows path

Set Windows path

Setting Windows path

Setting the Windows path

Set the path variable from the Windows command-line

Set the path variable from the Windows command line

Setting the path variable from the Windows command-line

Setting the path variable from the Windows command line

Set the path from the Windows command-line

Set the path from the Windows command line

Set the Path from Windows Command Line

Set the Path from Windows Command-Line

Set Path from Windows Command Line

Set Path from Windows Command-Line

Setting Path from Windows Command Line

Setting Path from Windows Command-Line

Setting the Path from Windows Command Line

Setting the Path from Windows Command-Line

Setting Path from the Windows Command Line

Setting Path from the Windows Command-Line

Set path from the Windows command-line

Set the path from the Windows command-line

Set the path variable from the Windows command-line


Set the path variable from the Windows CLI

Set the path variable from the Windows CLI

Setting the path variable from the Windows CLI

Setting the path variable from the Windows CLI

Set the path from the Windows CLI

Set the path from the Windows CLI

Set the Path from Windows CLI

Set the Path from Windows CLI

Set Path from Windows CLI

Set Path from Windows CLI

Setting Path from Windows CLI

Setting Path from Windows CLI

Setting the Path from Windows CLI

Setting the Path from Windows CLI

Setting Path from the Windows CLI

Setting Path from the Windows CLI

Set path from the Windows CLI

Set the path from the Windows CLI

Set the path variable from the Windows CLI


Set path from command line

Users can run an executable from windows command prompt either by giving the absolute path of the file or just by the executable file name. In the latter case, Windows searches for the executable in a list of folders which is configured in environment variables. These environment variables are as below.

The values of these environment variables can be checked in system properties (Run sysdm.cpl from Windows Run or Windows computer properties). Initially user specific path environment variable will be empty. Users can add paths of the directories having executables to this variable. Windows Administrators can modify the system path environment variable also.

How to set path from command line?

In Vista, Windows 7 and Windows 8 we can set path from command line using ‘setx’ command.

setx path “%path%;c:\directoryPath”

For example, to add c:\dir1\dir2 to the path variable, we can run the below command.

setx path “%path%;c:\dir1\dir2”

Alternative way is to use Windows Resource Kit tools ‘pathman.exe‘. Using this command we can even remove a directory from path variable. See download windows resource kit tools. This works for Windows 7 also.

Add directory to system path environment variable:

Open administrator command prompt

Run the below command

pathman /as directoryPath

Remove path from system path environment variable:

Run the below command from elevated command prompt

pathman /rs directoryPath

Setting user path environment variable

For user environment variables, Windows admin privileges are not required. We can run the below command to add a directory to user path environment variable.

pathman /au directoryPath

To remove a directory from user path, you can run the below command.

pathman /ru directoryPath

Default option is not allowed more than ‘2’ time(s)

You get this error if you have not enclosed ‘path’ in double quotes. See the below example for setting the path of Firefox.

C:\Users\>setx path %path%;“c:\Program Files (x86)\Mozilla Firefox\”

ERROR: Invalid syntax. Default option is not allowed more than '2' time(s).

Type “SETX /?” for usage.

Now if you move %path% to be in the double quotes

C:\Users\>setx path “%path%;c:\Program Files (x86)\Mozilla Firefox\”

SUCCESS: Specified value was saved.

C:\Users\>

Fair Use Source: https://www.windows-commandline.com/set-path-command-line/


User Variables: HKEY_CURRENT_USER\Environment

System Variables: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

reg queryHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment”

Fair Use Source: https://stackoverflow.com/questions/573817/where-are-environment-variables-stored-in-the-windows-registry

set_the_path_variable_from_the_windows_command-line.txt · Last modified: 2021/12/11 20:08 by 127.0.0.1