Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(GH-728) Fix: Env var changes may require reboot
Setting environment variables directly in the registry has a side effect of sometimes not letting explorer.exe know that something changed. When that happens, it doesn't matter if you open a new shell or not, the environment variables available to new shells will reflect the older values. The fix for this is a two fold attack - broadcast the change and set another environment variable with SetX. Broadcasting the change using the native method `SendMessageTimeout` has no effect on currently open shells, but helps GUIs and explorer.exe realize that something changed and that they should look to refresh their environment values. SetX.exe also has no effect on the current shell, but it forces explorer.exe to refresh the values that are available. Set a user environment variable with the current date and time. This also has a nice side effect of letting the user know the last time the environment was updated by Chocolatey. If either of these fail, report the error as a warning.
- Loading branch information