Windows – Path reset to old value after shutdown

pathwindows 10

I use a command line tools under windows 10. The path to the tool is set in the system PATH variable so that it can be started from the command line.

Whenever a new version of the tool comes out, I store it to a new directory and update the system PATH to point to the new location. Restart the command window and everything is fine, the new version of the tool is used.

After a ahutdown and start however, the PATH reverts back to the old value and the old version of the tool gets used. Opening the envoronment variable editor and clicking OK, without making any changes, solves the problem … until the next shutdown. I have searched the whole registry, the old PATH value is nowhere found. It must be stored somewhere else.

After some time, (I guess after a windows update gets installed, but I am not sure about this) the problem goes away and the new PATH value is remembered.

In previous windows versions this worked without problems, I see this behaviour only after upgrade to Windows 10.

How can this be fixed? Is there some way to make the effective PATH permanent?

Best Answer

  • This sounds a bit like a slight bug in Windows but here's my guess.

    I think you need to actually reboot your machine via Windows -> Power -> Reboot after changing the setting and not shut it down first.

    When you say

    Opening the envoronment variable editor and clicking OK, without making any changes, solves the problem ... until the next reboot.

    I suspect you mean until the next time you shutdown and then boot the machine. This distinction is important in Windows 8 and 10 because a shutdown is not the same as it was and a reboot is closer to an actual shutdown now.

    Shutdown now closes your user applications, logs you out and then puts the OS core into hibernation. When you restart your machine it un-hibernates the core and then allows you log back in. As the setting has been (at this stage) only applied to the current user profile then you get the default (old) path.

    Doing a proper reboot skips the hibernation step and lets the system boot from scratch, loading new settings and programs. This would be why a Windows update fixes your problem as well, because they perform a reboot rather than a shutdown and restart.

    There is some information here on how hybrid shutdown works.

    I say this seems like a slight bug because you quite rightly expect your change to get pushed down into to hibernated system, but as it is one that is easily fixed (by rebooting) I expect this sort of problem is one that is relatively low priority to fix.