The most efficient way to get most things done on Windows is via the graphical interface. Every now and then, though, you have to turn to the command line for troubleshooting, programming, or just working on your nerd cred.
But if you’re trying to run something that’s not natively part of Windows, you’ll need to add it to your PATH variable. That tells your system where to look for executables when you ask for them.
What is PATH?
Environment variables store data about a system’s environment so the system knows where to look for certain information. The PATH variable is one of the most well-known environment variables since it exists on Windows, Mac, and Linux machines and does a fairly user-facing job on all. Its actual form is just a text string containing a list of directory paths that the system will search every time you request a program.
This is 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 just type “python” to launch it in the future. Do that for any program you like, whether it launches a GUI (like Notepad) or works in the command line interface (like Python).
On Windows, PATH (capitalized by convention only, since Windows’ NTFS file system is not case-sensitive) points by default to the “C:\Windows” and “C:\Windows\system32” directories.
If you type
charmap into the command line, you’ll get a massive list of Unicode characters you can copy and use, for example. “notepad” runs Notepad, “msinfo32” gets you a list of your computer’s specs, and so on.
These programs can also be launched with the GUI. But if you’re already working in the command line, launching programs just by typing their names is a lot easier. This is especially true if you’re trying to launch a program that will open and run inside the command line interface, like Python or Node.js.
How do I edit the PATH variable?
The Windows GUI is pretty straightforward, so it’s probably the best way for most people to edit PATH.
Using the Windows GUI
1. Open “System Properties” and go to the “Advanced” tab. The easiest way to do this is by typing
environment variable into your Windows Search bar and clicking “Edit the system environment variables.”
Alternatively, you can go to “Control Panel -> System and Security -> System” and click “Advanced system settings;” type
sysdm.cpl into the Run command; or right-click “This PC,” select “Properties,” and click “Advanced system settings.” They all go to the same place.
2. Once you’re in the “Advanced” tab, click “Environment Variables … ”
3. The top box contains user variables, meaning any edits will only apply to your account. If you have multiple accounts on one machine and want the changes to affect everyone, edit the bottom box containing system variables instead.
4. Select the user or system Path variable (don’t let the title-case throw you; PATH and Path are the same in Windows) you want to edit and click the “Edit … ” button below the box.
6. If you’d rather browse to the folder and select it manually, use the “Browse” button to navigate to the folder where your executable is located and hit the “OK” button when you’re there.
7. If you want your program to launch slightly faster, you can use the “Move Up” and “Move Down” buttons to put its folder closer to the top so it’ll pop up more quickly in the directory search.
8. Open a new command-prompt window and test your program by typing in the name of the executable you want to launch. It won’t work in the current window since it’s still using the old PATH variable.
Edit PATH Variables Using Command Prompt
The Windows 10 GUI is very usable and should meet most peoples’ needs, but if you need to use the command line to set PATH and environment variables, you can do that too.
1. Open the command prompt as administrator, then enter the command
2. Scroll through the list of paths, then find the variable you want to edit. The variable name is the part before the ‘=’ sign, the variable value is the part after, which you will rename to the directory you want it point to.
3. With that in mind, to edit the PATH, enter the following command:
setx variable name "variable value"
You can use the following code to set your System PATH from the Command Prompt. (Run as administrator.) To use it to set your User PATH , just remove the
setx /M PATH "%PATH%;<path-to-executable-folder>"
If you have problems, it’s a good idea to read through the known issues with and fixes for the
setx command truncating the variable to 1024 characters or otherwise altering the variables. Definitely back up both your user and your system path variables first.
Frequent Asked Questions
1. Why would I need to edit PATH?
Chances are, if you’re reading this, you’ve run into something that requires you to add it to the PATH variable, so that’s probably what you should do. If you just want to add something to your PATH for easier access, though, that’s also fine. Just make sure it doesn’t interfere with the higher-priority programs.
2. Is there a Windows PATH length limit?
Yes, there is. So PATH-changing enthusiasts beware that the limit is 260 characters.
3. Can I disable the Windows PATH length limit?
Yes you can! Go to the Registry Editor, then within that navigate to:
In the right-side pane, double-click the entry called “LongPathsEnabled”, then change the “Value data” value from 0 to 1. Click OK, and you’re good to go.
Our latest tutorials delivered straight to your inbox