Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I update my PATH using either the built-in Environment Variables dialog, or something like Path Editor, and then open up a command-prompt, the changes to my PATH will not register with the console, depending on where the command-prompt was started from.

For example, if I edit my PATH and then start cmd.exe from the Start Menu or a shortcut on the Desktop, then my PATH looks fine: it has successfully been updated; however, if I start cmd.exe from a shortcut anywhere other than the Start Menu or Desktop, the new PATH does not get read and I get the old path instead. It's very strange.

I've tried running the command prompt from a shortcut on the desktop and it works fine; I then copy that exact same shortcut to a sub-folder on the desktop, and I get the non-updating PATH problem.

I realise this is quite hard to explain, so I created a screencast to show this issue in action.

Here's a screenshot of the Command Prompt shortcut as seen in that screencast:

Command prompt shortcut settings

This is on Windows Vista Home Premium SP2.

share|improve this question

When you start a new process (such as a new command line), it will pick up the environment variables from the process that is starting it. When the path is updated, only the process performing the update can know it has changed, and the setting doesn't propagate until you log back on (for per-user settings) or reboot (for system-wide settings)

share|improve this answer
However, the main explorer process will detect environment changes in Registry (the dialog box belongs to rundll32) and update its own environment automatically. (At least in XP it does so.) This is why changes are visible when starting cmd from a shortcut. – grawity Feb 11 '10 at 13:47
Rowland, this provided me with enough information to troubleshoot exactly why this was happening, although it didn't answer my question entirely. See my own answer for details. Thanks! – Charles Roper Feb 11 '10 at 13:50
Thanks for this answer! All I had to do was close my command prompt and open it again. – user1477388 Feb 4 '14 at 17:24
up vote 9 down vote accepted

As Rowland suggests, when starting a new process, it will read the environment variables from the process that is starting it. Therefore, when starting a command-prompt from the Start Menu or the Desktop, it reads the environment variables from explorer.exe which, as grawity suggests, detects changes to environment settings in the registry and thus I see my new PATH in command-prompts started from the Desktop or Start Menu.

The reason I do not see updates to my PATH in the screencast I posted is because I had initially launched an explorer window using FARR making FindAndRunRobot.exe the parent process. FARR doesn't automatically detect environment changes and so, child processes spawned from it do not pick up the new PATH. I also had 'Launch folder windows in a separate process' option set in Explorer which means that all explorer.exe windows I opened subsequent to the initial one opened by FARR where also children of FARR.

By turning-off the 'Launch folder windows in a separate process' option, new explorer.exe processes aren't created under FARR, which solves my problem. However, I also launch console windows and other things directly from FARR; these also get the old environment settings. If I restart FARR, then the new environment settings are propagated.

Here's a screenshot of Process Explorer showing processes spawned from FARR. None of these processes receive the new environment settings from the top-level explorer.exe unless I restart FARR:

process explorer

share|improve this answer
Why was my answer voted down? If there is a flaw in it, let me know and I'll try to fix it. – Charles Roper May 14 '10 at 10:50
make great sense. – lwpro2 Nov 6 '14 at 3:16

You must log in to answer this question.

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