On StackOverflow and on the net in general, there are outdated and few guides on how to add a specific folder to the Windows 10 Path environment variable of the user.
I think a complete guide for new developers with step by step instructions and screenshots could be really usefull to help them executing utilities from a Command Prompt without the need of the full path, simplifying the things.
To add a path to the PATH environment variableIn the System dialog box, click Advanced system settings. On the Advanced tab of the System Properties dialog box, click Environment Variables. In the System Variables box of the Environment Variables dialog box, scroll to Path and select it.
In the Environment Variables window (as shown below), highlight the Path variable in the System Variable section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon, as shown below.
For the guide below we want to add an example utility called mytool.exe which is located in C:\Users\NewFolderInPath\mytool.exe, so that everytime i want to execute the mytool utility i don't have to specify the full path.
I used this as an example, you can replace the folder with something more realistic like the JDK bin directory located here C:\Program Files\Java\{JDK_VERSION}\bin to execute javac, keytool or everything you want.
Step 1 - Click on the
Windowsicon

Step 2 - Click on the
Settingsicon

Step 3 - Click on
System

Step 4 - Click on
About

Step 5 - Click on
System info

Step 6 - Click on
Advanced system settings

Step 7 - Click on
Environment variables...

Step 8 - Select
Pathrow and then clickEdit

Step 9 - Click
Newand then clickBrowse, then in the next panel which will open you need to select the folder you want in thePath. For the initial premise of this guide i will add the folderC:\Users\NewFolderInPath

Step 10 - Click
OKand click everyOKbutton you will encounter to close every previous windows.

Step 11 - Open a
command prompt (cmd)and now you can execute your utility without specifying the full path.

NOTE : For every problems leave a comment below and i will answer as soon as i can. Good luck and happy coding :)
To print each entry of Windows PATH variable on a new line, execute:
C:\> echo %PATH:;=&echo.%
Set Windows PATH variable for the current session:
C:\> set PATH=%PATH%;C:\path\to\directory\
Set Windows PATH Permanently
Run as Administrator: The setx command is only available starting from Windows 7 and requires elevated command prompt.
Permanently add a directory to the user PATH variable:
C:\> setx path "%PATH%;C:\path\to\directory\"
Permanently add a directory to the system PATH variable (for all users):
C:\> setx /M path "%PATH%;C:\path\to\directory\"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With