WiX卸载 - 在重启管理器之前关闭应用程序

Ivo*_*hev 3 install wix uninstall restart

我安装了WiX安装程序.安装完成后,它会启动一个在Explorer进程中注入一些代码的应用程序.

目前,当我卸载时,Restart Manager启动并提供关闭我的应用程序和资源管理器.而不是我想手动关闭我的应用程序(这是通过在命令行上使用-exit再次运行它来完成的).我有一个自定义动作来做到这一点.

这是我到目前为止所尝试的:

<CustomAction ExeCommand="-exit" FileKey="MyApp.exe" Id="CloseMyApp" Impersonate="yes" Return="ignore" />

<InstallExecuteSequence>
    <RemoveExistingProducts After="InstallInitialize" />
    <Custom Action="CloseMyApp" Before="RemoveFiles" />
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)

这不起作用.操作在Restart Manager会话之后完成.因此,重新启动管理器弹出并要求关闭我的应用程序和资源管理器.该操作稍后运行,但到那时应用程序已经消失.

那么我试过这个:

<InstallExecuteSequence>
    <RemoveExistingProducts After="InstallInitialize" />
    <Custom Action="CloseMyApp" Before="RemoveExistingProducts" />
</InstallExecuteSequence>
Run Code Online (Sandbox Code Playgroud)

这也行不通.行动太迟了.我也得到"警告LGHT1076:ICE63:某些操作属于InstallInitialize和RemoveExistingProducts.".

基本上 - 如何在卸载期间和Restart Manager会话之前执行自定义操作?

我猜我是否使用Impersonate ="no"它可能会在正确的时间运行,但这不是一个选项.这是因为新进程必须为必须关闭的进程运行相同的用户,因为它查找其窗口并发送消息.如果进程属于不同的用户,那就太麻烦了.

有任何想法吗?

Rob*_*ing 5

您需要在InstallValidate之前运行CloseMyApp自定义操作,因为这是处理重新启动管理器的时间(doc).或者,您可以使用MSIDISABLERMRESTART或MSIRESTARTMANAGERCONTROL属性禁用重新启动管理器.