简体   繁体   English

更改PATH后必须重新启动

[英]Must reboot after changing PATH

It could be that this is no strictly speaking a WIX issue, but it should be a well known problem related to setup with well established best practices. 严格来讲,这可能不是WIX问题,但它应该是一个与建立良好的最佳实践有关的众所周知的问题。 I just can't find these practices on Google. 我只是在Google上找不到这些做法。 Using WiX 3.6, Windows 7, Visual Studio 2008, but the installation must support Windows from XP to newer. 使用WiX 3.6,Windows 7,Visual Studio 2008,但安装必须支持从XP到更高版本的Windows。

I'm installing a COM object that depends on some third party DLLs. 我正在安装依赖于某些第三方DLL的COM对象。 The object itself is registered okay, and all the DLLs are installed in installation folder, and setup adds this folder to system's PATH environment variable. 该对象本身已注册好,并且所有DLL都安装在安装文件夹中,安装程序将此文件夹添加到系统的PATH环境变量中。 The code looks like this: 代码如下:

<Component Id="RequiredLibraries" Guid="$(var.RequiredLibrariesGUID)">
    <?include redist.wxi?>
    <Environment Id="PATH" Name="PATH" Value="[INSTALLDIR]" Permanent="no" Part="last" Action="set" System="yes" />
</Component>

On my machine I can use the object immediately after installation, but on some machines I must reboot the computer. 在我的机器上,安装后我可以立即使用该对象,但是在某些机器上,我必须重新启动计算机。 This reboot is a pain, and I don't know why is it necessary, nor why only on some machines. 重新启动很痛苦,我不知道为什么有必要,为什么不只在某些计算机上。 I can <ScheduleReboot After="InstallFinalize"/> , but I'm hoping for some better solution. 我可以<ScheduleReboot After="InstallFinalize"/> ,但是我希望有更好的解决方案。 So, feel free to answer any of these questions: 因此,请随时回答以下任何一个问题:

  1. What is the best common practice for this issue? 此问题的最佳常规做法是什么? I can't pack everything to a single DLL, so I need a solution for several DLLs. 我无法将所有内容打包到单个DLL中,因此我需要针对多个DLL的解决方案。

  2. What I could I do to enable the use of the COM object (by making the change to PATH visible to the rest of the system), without resorting to reboot, or user relogin, or Explorer restart? 我该怎么做才能启用COM对象(通过使PATH的更改对系统的其余部分可见),而无需重新启动,用户重新登录或Explorer重新启动? Does Windows Installer broadcasts WM_SETTINGCHANGE message? Windows Installer是否广播WM_SETTINGCHANGE消息? Should I broadcast it in custom action? 我应该以自定义动作播放它吗?

  3. How could I detect and ask the user to reboot/relogin only if it is required, and not always? 我如何才能检测并仅在需要时才要求用户重新启动/重新登录,而并非总是如此? (reboot is not required on some machines) (在某些计算机上不需要重新启动)

  4. How can I schedule something less painful than reboot that works just as well? 我如何安排比重新启动同样痛苦的事情呢?

There are two scenarios I know of: 我知道两种情况:

1) Application doesn't honor WM_SETTINGCHANGE broadcasts ( typically anything hosted by service control manager ) 1)应用程序不支持WM_SETTINGCHANGE广播(通常由服务控制管理器托管)

2) A behavior in MSI when it chooses not to send the broadcast. 2)MSI选择不发送广播时的行为。 Per WriteEnvironmentStrings Action : Per WriteEnvironmentStrings操作

(emphasis added) (强调)

Environment variables do not change for the installation in progress when the WriteEnvironmentStrings action or RemoveEnvironmentStrings action are run. 运行WriteEnvironmentStrings操作或RemoveEnvironmentStrings操作时,正在进行的安装的环境变量不会更改。 On Windows 2000, Windows Server 2003, Windows XP, and Windows Vista this information is stored in the registry and a WM_SETTINGCHANGE message is sent to notify the system of the changes when the installation completes. 在Windows 2000,Windows Server 2003,Windows XP和Windows Vista上,此信息存储在注册表中,并在安装完成后发送WM_SETTINGCHANGE消息以将更改通知系统。 Another process can receive notification of the changes by handling these messages. 另一个进程可以通过处理这些消息来接收更改的通知。 No message is sent if a restart of the system is pending. 如果等待系统重新启动,则不会发送任何消息。 A package can use the MsiSystemRebootPending property to check whether a system restart is pending. 程序包可以使用MsiSystemRebootPending属性来检查系统重新启动是否挂起。

I've worked around #2 by writing a .NET custom action (using Environment class) that makes a meaningless change just to get the broadcast to occur after MSI has done it's thing. 我通过编写.NET自定义操作(使用Environment类)解决了#2的问题,该操作进行了无意义的更改,只是为了使广播在MSI完成后才发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM