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

发布于 2024-09-06 21:27:29 字数 1124 浏览 5 评论 0 原文

我有一个用 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梨涡 2024-09-13 21:27:29

您需要在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文