To make it easy to run programs from the command line, you can add a directory or program to the Windows PATH. Here is how to do it.
Windows has several built-in environment variables responsible for several different features and makes your life a tad bit easier. One of the most popular and useful Windows Variables is the PATH variable. The PATH variable allows you to add directories of executables so that it is easy to use them via the command line.
Generally, you don’t have to use the command line much in Windows. However, some programs may require or function better when using them via the command line. For example, FFMPG is a command-line tool. As such, adding FFMPEG to Windows PATH will make it easy to use the FFMPEG tool to download streaming videos. Similarly, if you use a specific application or program from the command line, you can add that executable’s directory to the Windows PATH. That way, you don’t have to open the Command Prompt or PowerShell window in the executable folder. Instead, you can use the program command directly as the path is already added to the Windows PATH, and the operating system knows where to look.
So, without delay, let me show you how to add a directory or a program to Windows PATH in Windows 10 and 11.
What is the PATH variable in Windows?
PATH is one of the system variables in Windows. The primary function of PATH is to let Windows know where to look for a program when running it from the command line. By default, most system programs are added to the PATH variable. That is why you don’t have to specify the absolute program path or open the command line window in the program directory while running a command related to system applications.
You will also find the PATH variable in other operating systems like Linux and macOS.
Can I edit the PATH variable?
Yes. You can edit the Windows PATH variable from the Environment Variables screen.
There are two kinds of PATH variables in Windows. i.e., User PATH variable and System PATH variable. As you can guess, anything thing added to the User PATH variable is only applicable to your user account. To apply the path system-wide (all users), you must add the directory or program to the System PATH variable.
Add directory or program to Windows PATH
To add to PATH in Windows, we need to open the Environment Variables tool. Here is how.
- Press the Start key on your keyboard.
- Search and open “Edit the system environment variables.”
- Go to the “Advanced” tab.
- Click the “Environment variables” button.
- Select the “Path” variable under “User variables” or “System variables.”
- Click the “Edit” button.
- Press the “New” button.
- Type the full directory path of the program.
- Press “Enter” to confirm the path.
- Click “Ok.”
- Press the “Ok” button in the Environment Variables window.
- Click “Ok” in the System Variables window.
Detailed steps:
First, we need to open the Environment Variables tool. To do that, search for “Edit the system environment variables” and click on the result. Here, make sure you are in the “Advanced” tab, and click on the “Environment Variables” button.
The above action will open the “Environment Variables” window. Select the “Path” variable under the “User Variables” or “System Variables” section. To limit the path to your user account, select the Path variable under the User Variables section. To apply the path to all users. i.e., system-wide, select the Path variable under the System Variables section. I’m choosing the Path variable under the User Variables section.
After selecting the Path variable, click on the “Edit” button under that section.
Now, click the “New” button to add a new path to Windows PATH.
Type the full path of the executable directory and click the “Ok” button. For example, suppose the full executable path is “C:\users\windowsloop\app\program.exe,” you need to type “C:\users\windowsloop\app\” in the blank field. Next, click the “Ok” button to save the changes.
Click “Ok” in the Environment Variables section.
Press the “Ok” button in the System Properties window.
That is it. You have successfully added a directory or program to Windows PATH. From now on, you can start using that program directly in any command-line tool.
Important note: After adding a directory or program to Windows PATH, you must close and re-open the command line tools. Otherwise, they might not recognize the changes in the PATH variable.
I hope that helps.
If you are stuck or need some help, comment below, and I will try to help as much as possible.