Windows – Why Changes to PATH Are Not Recognized

command linepathwindowswindows-vista

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.

Best Answer

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)

Related Question