16

I am unable to update my system environment variable PATH. I don't receive any error message when editing PATH, but the change doesn't take. I have Windows 10. I am an admin user. Here are the steps I take to edit PATH.

  1. I Search for and open "View advanced system settings".
  2. Click the "Environment Variables" button.
  3. Locate "Path" under the System variables section. Click to highlight it.
  4. Click "Edit". The "Edit environment variable" modal window pops up.
  5. There are lots of paths listed in the listbox. Click New to add a new item.
  6. A blank space for the new folder is highlighted in the listbox. Click Browse. Select a folder. Click OK. The browsed path is in the listbox.
  7. Click "OK" on the Edit environment variable modal.
  8. Close all existing cmd windows if any are open. Open a new cmd window.
  9. type echo %PATH%

I expect my added PATH to be shown, but it is not. If I repeat the steps above, my newly added folder is not in the listbox on the "Edit environment variable" model when I click to edit the PATH system environment variable the second time. I also expected Windows to prompt me for elevated admin privileges at some point when editing the environment variable, but this never happens. What am I doing wrong?

4
  • and if you just add ;<path>; at the end of the path string, does that stick? Aug 2, 2016 at 3:12
  • 2
    Do you mean set path=%path%;C:\whatever\bin in a command window? That will set it for the current session, but it won't persist once I close that window.
    – user28496
    Aug 2, 2016 at 16:01
  • no, I mean System.cpl -> Advanced System Settings -> Environment Variables, and in the bottom pane, scroll down to Path, double click it, and you will see a text box with your system path as a string. click in "variable value", and hit "End" to jump to the end of the string. add a trailing semicolon if none exists, and then type in your path (in quotes, if it has spaces). then add another trailing semi, and click OK. Aug 2, 2016 at 18:00
  • It doesn't stick. After I set the environment variable, it shows up in the list of folders in the "Edit environment variable" modal, but once I close it and reopen it, the folder I've added is gone.
    – user28496
    Aug 3, 2016 at 3:52

5 Answers 5

19

Did you try hitting OK to close the main Environment Variables window too? I just tried and when I edit the path and hit OK to close the Edit window, it doesn't show up. When I then hit OK and close the Environment Variables window, it shows up (after closing any existing CMD windows and opening a new one).

FYI, be careful with the steps you listed though. I find that when I hit New, then click browse and select a path, it ends up overwriting the previous path on the list instead of adding a new one. I've been hitting New, then typing something like "x". Then clicking Browse while "x" is highlighted to select the path. This looks like a bug with the new path editor.

2
  • 2
    The problem was that I was closing the window without hitting OK. I'm not a total dummy though. Even though my screen has 3200x1800 resolution, the text scaling is so high that the dialog doesn't fit on the screen, and it doesn't look like any buttons are chopped off. !Windows Environment Variables
    – user28496
    Aug 3, 2016 at 3:56
  • 1
    closing the cmd window and opening a new one did the trick form me :) Jul 19, 2020 at 22:46
4

If you use any variable within another variable, this variable type must be set as REG_EXPAND_SZ in the Windows Registry. (Ex: PATH = %JAVA_HOME%\bin;...)

You can check it on the Registry (for User variables):

HKEY_CURRENT_USER\Environment\PATH 

For System Variables, check on

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

I had the same problem and changing it solved this issue for me.

enter image description here

1
  • 1
    This fixed the problem for me after I restarted the session (logged out/in). Thank you.
    – bitRAKE
    Sep 29, 2022 at 14:13
1

I was having the same problem. I think it's a bug. But I found a solution: On the environment variables window chose the path which you want to add or change (either system or user one) and click edit. on the edit windows however dont chose modify or new. instead click the edit text button below. add a new path or change and existing one (don't forget to use ";" if you are adding a new path) and click accept. when you back to environment variables windows click the path again and hit enter since there is no accept or ok button on this window. (I m not sure if this last step was necessary or not but I did it this way and it worked. did not try again without this last step.) hope it helps.

0
0

Do the following:

  1. setx PATH "C:\myfolder;%PATH%"

  2. Open a new cmd session. (As setx activates from new session)

Credit: https://www.opentechguides.com/how-to/article/windows-10/113/windows-10-set-path.html

0

I had the same problem and found that closing the cmd window and opening a new one forces it to read the new environment variables.

1
  • I don't think this is too related to the specific issue, if it is, could you explain how exactly?
    – Destroy666
    Apr 30, 2023 at 13:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .