设置环境变量需要在 64 位上重新启动
我正在使用 Wix 3.5 开发一个安装程序,需要设置系统 PATH 环境变量。
这就是我设置环境变量的方式:
<Directory Id="DirectoryName">
<Component Id="ComponentID" Guid="{BE20AF67-5943-4AF4-BE66-226E2D4B844F}">
<Environment Id="EnvironmentID" Name="PATH" Action="set" Value="the path" Part="last" Separator=";" System="yes" />
</Component>
</Directory>
这似乎适用于 32 位系统,无需重新启动即可识别更改。但是,当我在 64 位 Windows 7 上尝试时,需要重新启动。
这是 64 位系统上的已知问题吗?
也许最好的方法是安排重新启动以覆盖所有基地。
谢谢, 艾伦
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:
<Directory Id="DirectoryName">
<Component Id="ComponentID" Guid="{BE20AF67-5943-4AF4-BE66-226E2D4B844F}">
<Environment Id="EnvironmentID" Name="PATH" Action="set" Value="the path" Part="last" Separator=";" System="yes" />
</Component>
</Directory>
This seems to be working on 32-bit systems without requiring a reboot for the changes to be recognized. However, when I try it on 64-bit Windows 7 a reboot is required.
Is this a known issue on 64-bit systems?
Maybe the best approach would be to schedule a reboot to cover all bases.
Thanks,
Alan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 ServerFault 上检查此问题:How do you add a Windows环境变量无需重新启动?
因此,要将更改传播到环境变量列表,您可以编写一个小程序来广播
WM_SETTINGCHANGE
消息,如知识库文章 如何将环境变量传播到系统。Check this question on ServerFault: How do you add a Windows environment variable without rebooting?
So to propagate the change to the list of environment variables, you can write a small program which broadcasts
WM_SETTINGCHANGE
message as described in KB article How to propagate environment variables to the system.当您添加或设置环境变量时,
WM_SETTINGCHANGE
消息将发送到所有程序以通知它们更改。但是,任何已经运行的程序都不会获得更新的环境,除非它本身可以处理此消息。重新启动系统会更新每个程序。无需重新启动的解决方法:
总而言之,为了让每个用户都能使用它,您仍然需要重新启动。
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:
So summing-up, in order to get this to work for every user, you still need to reboot.