The most efficient way to do most things on Windows is through the GUI. From time to time, however, you have to turn to the command line for troubleshooting, programming, or just working on your nerd credo. But if you’re trying to run something that isn’t natively part of Windows, you’ll have to add it to your PATH variable. This tells your system where to look for executables when you request them.
What is PATH?
Environment variables store data about a system’s environment so that the system knows where to look for certain information. The PATH variable is one of the best known environment variables because it exists on Windows, Mac and Linux machines and does a fairly user-friendly job. Its actual form is just a text string containing a list of directory paths that the system will look for each time you ask for a program.
It’s a bit like adding a desktop shortcut to your command line. Instead of entering “C: Users username AppData Local Programs Python Python38-32 python.exe” to launch Python, you can add the folder containing the file to the PATH variable and simply type “python “to launch it in the future. Do this for any program you like, whether it launches a graphical interface (like Notepad) or works in the command line interface (like Python).
On Windows, PATH (capitalized by convention only, because the Windows NTFS file system is not case-sensitive) points by default to the directories “C: Windows” and “C: Windows system32” . If you type
charmap in the command line, you will get a massive list of Unicode characters that you can copy and use, for example. “Notepad” runs Notepad, “msinfo32” provides you with a list of specifications for your computer, etc.
These programs can also be launched with the graphical interface. But if you’re already working from the command line, launching programs by simply typing in their names is much easier. This is especially true if you are trying to launch a program that will open and run inside the command line interface, like Python or Node.js.
How to edit the PATH variable?
The Windows GUI is fairly simple, so it’s probably the best way for most people to modify PATH.
Using the Windows GUI
1. Open “System Properties” and go to the “Advanced” tab. The easiest way to do this is to type
environment variable in your Windows search bar and clicking on “Modify system environment variables”.
Alternatively, you can go to “Control Panel -> System and Security -> System” and click on “Advanced System Settings;” type
sysdm.cpl in the Execute command; or right-click “This PC”, select “Properties”, then click “Advanced System Settings”. They all go to the same place.
2. Once in the “Advanced” tab, click on “Environment variables …”
3. The upper area contains user variables, which means that all changes will only apply to your account. If you have multiple accounts on a single machine and the changes affect everyone, modify the lower area containing the system variables instead.
4. Select the user or system path variable (do not let the case of the title throw you away; the PATH and the path are the same in Windows) that you want to modify and click on the “Modify …” button under the box .
6. If you prefer to browse the folder and select it manually, use the “Browse” button to navigate to the folder where your executable is located and press the “OK” button when you are there.
7. If you want your program to launch a little faster, you can use the “Move up” and “Move down” buttons to place its folder higher so that it appears faster in search in the directory.
8. Open a new command prompt window and test your program by typing the name of the executable you want to launch. This will not work in the current window because it still uses the old PATH variable.
The Windows 10 GUI is very usable and should meet the needs of most people, but if you have to use the command line to set the PATH, you should know that it is not as simple as there appears. It is a good idea to read about known issues and fixes
setx command truncating the variable to 1024 characters or otherwise modifying the variables. Permanently save both your user and your system path variables.
With this disclaimer, you can use the following code to define your system path from the command prompt. (Run as administrator.) To use it to set your user PATH, simply delete the
Do I have to change the PATH?
Chances are, if you’re reading this, you come across something that forces you to add it to the PATH variable, that’s probably what you should do. If you just want to add something to your PATH for easier access, that’s fine too. Just make sure it doesn’t interfere with priority programs.
If you have to work with environment variables regularly and want something a little more powerful than the default Windows GUI or command line, Quick Environment Editor works pretty well. It even includes tools to help you remove duplicate and / or broken paths. Remember to back up your computer before making any changes.
Is this article useful?