Windows provides the PATH variable in order to store executable and binary file locations in order to search, find, and execute them. In order to call a command or binary directly from the command line interface without providing the absolute or full path. In this tutorial, we will learn how to add a new path into the PATH environment variable.
The following instructions can be used for different Windows operating system versions without any difference. Feel free to use these instructions for Windows 7, Windows 8, Windows 10, and Windows Server series.
Add New Path to PATH Environment Variable via Environment Variables GUI
Windows provides the Environment Variables configuration in order to change or add a new PATH. The Environment Variables can be opened in different ways. The most practical and easy way is typing “environment” to the Start Menu. This will list the “Edit the system environment variables” like below.
The following “System Properties” screen will appear. From there select the Environment Variables button.
The Environment Variables screen is like below as we can see there are two types of environment variables. User variables for ismail are special to the current user named ismail and can not be used by other users. The System variables are used by all users and provided as system-wide. In this case, we will add the System-wide Path variable. First, we find the Path variable and select it. Then click on the Edit which will open the PATH variable editor.
The Path variable configuration screen is like below. Currently, existing variables are listed below we can delete, change them but for this case, we will add a new Path to the path variable. Just click on the New button which will add a new list to the list and put the cursor there. Just type the path you want to add which is in this case “D:\bin”. The last step is clicking on the OK button which will apply the new Path variable with the added new value.
The newly added Path environment variables can be tested in different ways. For example, if there are some binary in the added path the binary can be called from the command-line interface.
Add New Path to PATH Environment Variable via PowerShell Command Line Interface
PowerShell provides the $env variables in order to access, use, or edit environment variables. The PATH environment variable can be accessed via $env.PATH. In order to add a new path, we will use the plus and equal operators which will add a new path to the existing path end.
$env:PATH += ";D:\bin"
Alternatively thy syntax can be changeed in a more readable format like below.
$env:PATH = $env:PATH + ";D:\bin"
The newly added PATH environment variable can be listed with the following PowerShell command.