58

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.

wdmssk
  • 33
  • 1
  • 2
  • 4
MatPag
  • 41,742
  • 14
  • 105
  • 114

2 Answers2

110

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 Windows icon

enter image description here

Step 2 - Click on the Settings icon

enter image description here

Step 3 - Click on System

enter image description here

Step 4 - Click on About

enter image description here

Step 5 - Click on System info

enter image description here

Step 6 - Click on Advanced system settings

enter image description here

Step 7 - Click on Environment variables...

enter image description here

Step 8 - Select Path row and then click Edit

enter image description here

Step 9 - Click New and then click Browse, then in the next panel which will open you need to select the folder you want in the Path. For the initial premise of this guide i will add the folder C:\Users\NewFolderInPath

enter image description here

Step 10 - Click OK and click every OK button you will encounter to close every previous windows.

enter image description here

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

enter image description here

starball
  • 20,030
  • 7
  • 43
  • 238
MatPag
  • 41,742
  • 14
  • 105
  • 114
  • 3
    In addition to this walkthrough this video was helpful - https://www.youtube.com/watch?v=extCL1UU5wk and so was this one https://www.youtube.com/watch?v=gBHOeI5QB8M in understanding what test command to try and that it wont work until you close out of command prompt and reopen it (looks like I have keytool running now :) – NukeouT Jun 10 '17 at 22:58
  • 17
    tip - just type 'env' in the start menu - select 'edit environment variables' top item to skip half these steps – niico Sep 18 '19 at 23:03
  • 2
    If you type 'environment' into the start menu it also gives you the option for whether to edit variables for the current user of the system. The instructions above require admin privileges so for me end up editing the admin account's path instead of my regular user's account (my company's IT dept are sadists so I have multiple accounts). – Mog0 Jun 05 '20 at 15:04
15

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\"

HackSlash
  • 4,944
  • 2
  • 18
  • 44