Wix:是否可以在InstallValidate之前执行自定义操作?

jch*_*cha 6 service custom-action wix

在卸载过程中,安装程序将显示以下消息:

"The setup must update files or services that cannot be updated while the system is running. If you choose to continue, a reboot will be required to complete the setup."
Run Code Online (Sandbox Code Playgroud)

我认为这是由于卸载时安装的服务仍在运行引起的。因此,我尝试编写一个自定义操作来停止它。但是,这似乎不起作用。

如果将动作设置为Execute='deferred' Impersonate='no',则仅允许我在InstallInitialize和之间放置动作InstallFinalize,因此我必须将其设置为“立即”。

<CustomAction BinaryKey='CustomActions' Id='StopService' DllEntry='StopService' Execute='immediate' />

<Custom Action="StopService" Before="InstallValidate">REMOVE="ALL"</Custom>
Run Code Online (Sandbox Code Playgroud)

另请注意,由于某些原因,我必须使用自定义操作来手动安装服务,而不是使用Wix。这就是为什么我试图手动将其删除。

Bob*_*son 4

您无法在 InstallInitialize 之前运行提升的自定义操作。如果您正常安装该服务,MSI 将负责为您停止该服务,并且不会显示正在使用的消息。