Author neeverett
Recipients neeverett, paul.moore, steve.dower, tim.golden, zach.ware
Date 2017-05-15.17:48:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I was trying to add Python to Windows PATH and found this tool. But after I ran it and restarted the Command Prompt, nothing seemed to be changed: Command Prompt still didn't recognize Python codes. Finally I got it done by manually setting the environment variables in Windows System Properties.

Then I tried to figure out what was wrong with this script and found that it does not take effect until a reboot or log off. It's not mentioned in the content or output of the script, making it puzzling.

The cause of this inconvenience is that though the script changes the env vars, applications don't refer to the new values automatically. It is explained in a Microsoft KB article( -- "However, note that modifications to the environment variables do not result in immediate change. For example, if you start another Command Prompt after making the changes, the environment variables will reflect the previous (not the current) values. The changes do not take effect until you log off and then log back on."

The article also provided a method to refresh the environment variables immediately  -- "To effect these changes without having to log off, broadcast a WM_SETTINGCHANGE message to all windows in the system, so that any interested applications (such as Windows Explorer, Program Manager, Task Manager, Control Panel, and so forth) can perform an update."

I am going to create a PR which implements it by using ctypes.windll.user32.SendMessageTimeoutW() to broadcast the WM_SETTINGCHANGE message.
Date User Action Args
2017-05-15 17:48:25neeverettsetrecipients: + neeverett, paul.moore, tim.golden, zach.ware, steve.dower
2017-05-15 17:48:25neeverettsetmessageid: <>
2017-05-15 17:48:25neeverettlinkissue30374 messages
2017-05-15 17:48:24neeverettcreate