What is Windows PATH and how do I add elements to it?

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.

Windows Python path example

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).

Windows Path Charmap launchedWindows Path Charmap launched

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.

READ:   What to do when Windows doesn't recognize your Android device

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”.

Finding Windows Path System PropertiesFinding Windows Path System Properties

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 …”

Advanced Windows Path system propertiesAdvanced Windows Path system properties

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.

Windows path environment variablesWindows path environment variables

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 .

Windows Path Edit environment variableWindows Path Edit environment variable

5. If you already have the path to the folder you want to add, simply click “New” and paste the full path (not directly into the executable, just in the folder that contains it). I paste the path to my NodeJS directory to be able to use JavaScript in the command line.

Windows Path Edit New environment variableWindows Path Edit New environment variable

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.

Windows Path Edit Environment variables Navigation nodeWindows Path Edit Environment variables Navigation node

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.

READ:   How to use your iPhone as a webcam

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.

Windows Path Cmd SetxWindows Path Cmd Setx

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 /M.

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.

READ:   We were unable to complete the installation because an update service was stopping

Related:

Is this article useful?

!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version=’2.0′;
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,’script’,
‘https://connect.facebook.net/en_US/fbevents.js’);
fbq(‘init’, ‘400239050508508’);
fbq(‘track’, ‘PageView’);

Leave a Reply