If you are a coder or programmer, you probably spend a decent amount of time using the command line to execute programs or compile code. To accomplish these tasks, you will most likely need to use a command from a library or software package installed (such as Python) on your system.
By default, most of these programs will add their own shortcuts to Windows environment variables. The most commonly used environment variable on Windows is probably the PATH variable. Basically, it allows you to run any executable files located inside the paths specified in a variable on the command line, without having to specify the full path to the executable.
In this article, I’ll show you how you can add additional paths to your Windows PATH if you want to run executables from your own directories. It’s worth noting that the procedure below is for Windows 10, but almost the same for Windows 7.
Add directories to PATH Variable
To get started, right-click on the “Computer” or “This PC” icon on your desktop and select “Properties.” If you don’t already have this icon on your desktop, you can easily add the missing icons to your desktop.
On the System dialog page on the left, you will see the Advanced System Settings link.
The System Properties dialog box opens and should already be open on the Advanced tab. Go ahead and click the Environment Variables button at the very bottom.
In the Environment Variables dialog box, you will see two sets of variables, one for user-defined variables and one for system variables. Both lists have a PATH variable, so you need to decide which one to edit.
If you only need commands for your account, edit the user variable. If you need it to work on the computer system no matter what user is logged in, edit the system variable. Click Path, then click Modify.
In the Edit Environment Variable dialog box, you will see a list of all the paths that are currently in the PATH variable. As you can see, Node.js and Git have already added their paths, so I can run Git and Node.js commands from anywhere on the command line.
To add a new path, simply click New and a new line will be added to the end of the list. If you know the path, just enter it or copy and paste. Optionally, you can also click the Browse button and navigate to the desired path.
To edit any path, just select it and click the “Edit” button. You can also delete paths using the Delete button. Note that you can also move items up and down the list. When you enter a command at the command prompt, Windows must search each directory stored in the PATH variable to see if this executable exists or not. If you want your executable to be faster, just move that path up the list.
This can also come in handy if you have multiple versions of the same command on different paths and need to run one instead of the other. The one displayed above in the list will be launched when you enter the command.
Finally, if you click Edit Text, a dialog will open where you can edit the Path variable using the old interface where all paths are listed in a single text box.
That’s all! If you want to know more about environment variables, be sure to check out my post on how to create your own environment variables. Enjoy!