我有一个用 WiX 完成的安装程序。安装完成后,它会启动一个应用程序,在资源管理器进程中注入一些代码。
目前,当我卸载时,重新启动管理器会启动并关闭我的应用程序和资源管理器。相反,我想手动关闭我的应用程序(这是通过在命令行上使用 -exit 再次运行它来完成的)。我有一个自定义操作可以做到这一点。
这是我到目前为止所尝试的:
<CustomAction ExeCommand="-exit" FileKey="MyApp.exe" Id="CloseMyApp" Impersonate="yes" Return="ignore" />
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize" />
<Custom Action="CloseMyApp" Before="RemoveFiles" />
</InstallExecuteSequence>
这不起作用。该操作是在重新启动管理器会话之后完成的。因此,重新启动管理器会弹出并要求关闭我的应用程序和资源管理器。该操作稍后运行,但那时应用程序已经消失了。
然后我尝试了这个:
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize" />
<Custom Action="CloseMyApp" Before="RemoveExistingProducts" />
</InstallExecuteSequence>
这也行不通。行动还是太晚了。我还收到“警告 LGHT1076:ICE63:某些操作介于 InstallInitialize 和 RemoveExistingProducts 之间。”。
基本上 - 如何在卸载期间和重新启动管理器会话之前执行自定义操作?
我猜如果我使用 Impersonate="no" 它可能会在正确的时间运行,但这不是一个选择。这是因为新进程必须为与必须关闭的进程相同的用户运行,因为它会查找其窗口并发送消息。如果进程属于不同的用户,那么做到这一点就困难得多。
有什么想法吗?
I have an installer done with WiX. When it's done installing, it starts an application that injects some code in the Explorer process.
Currently when I uninstall, the Restart Manager kicks in and offers to shut down my application and Explorer. Instead of that I want to close my application manually (this is done by running it again with -exit on the command line). I have a custom action that does it.
Here's what I tried so far:
<CustomAction ExeCommand="-exit" FileKey="MyApp.exe" Id="CloseMyApp" Impersonate="yes" Return="ignore" />
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize" />
<Custom Action="CloseMyApp" Before="RemoveFiles" />
</InstallExecuteSequence>
This doesn't work. The action is done way after the Restart Manager session. So the Restart Manager pops up and asks to close my app and Explorer. The action runs later, but by then the app is already gone.
So then I tried this:
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize" />
<Custom Action="CloseMyApp" Before="RemoveExistingProducts" />
</InstallExecuteSequence>
This also doesn't work. The action is done too late still. I also get "warning LGHT1076 : ICE63: Some action falls between InstallInitialize and RemoveExistingProducts.".
So basically - how do I execute my custom action during uninstall and before the Restart Manager session?
I'm guessing if I use Impersonate="no" it might run at the right time, however that's not an option. That's because the new process must run for the same user as the process that has to close because it looks up its window and sends messages. That's much trickier to do if the processes belong to different users.
Any ideas?
发布评论
评论(1)
您需要在 InstallValidate 之前运行 CloseMyApp 自定义操作,因为这是处理重新启动管理器的时间 (文档)。或者,您可以使用 MSIDISABLERMRESTART 或 MSIRESTARTMANAGERCONTROL 属性禁用重新启动管理器。
You would need the CloseMyApp custom action to run before InstallValidate since that is when the restart manager is processed (doc). Alternatively, you could disable restart manager with MSIDISABLERMRESTART or MSIRESTARTMANAGERCONTROL Properties.