Setting environment variables requires reboot on 64-bit

前端 未结 2 1088
一向
一向 2020-12-15 17:02

I am working on an installer using Wix 3.5 that needs to set the system PATH environment variable.

This is how I am setting the environment variable:



        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 17:25

    When you add or set an environment variable, a WM_SETTINGCHANGE message is sent to all programs to inform them of the change. However, any already running program will not get the updated environment, unless it can handle this message itself. Rebooting the system updates every program.

    A workaround without rebooting:

    1. Kill and restart explorer.exe, allthough this does not work for every running process, and only for the current logged on user.
    2. Restart the process or program you want to use, ie. try this out with cmd.exe. Again, this only works for the logged on user.

    So summing-up, in order to get this to work for every user, you still need to reboot.

提交回复
热议问题