卸载前停止服务和托管应用程序

发布于 2024-08-27 05:31:47 字数 814 浏览 6 评论 0原文

我有一项服务 MyService.exe 正在照顾我的应用程序 MyApp.exe,这意味着它会在该应用程序崩溃或发生其他情况时启动该应用程序。基本上,当服务停止时,应用程序(由服务)停止,当服务启动时,应用程序由服务启动。

为了停止我的服务并在卸载时停止我的应用程序,我正在做:

<ServiceControl Id='MyServiceControl' Name='MyServiceForTest' Start='install' Stop='uninstall' Remove='uninstall'/>

但是当我想卸载所有内容时,我收到错误消息:“安装程序必须更新系统运行时无法更新的文件或服务。如果如果您选择继续,则需要重新启动才能完成设置。”。如果我在运行卸载程序之前手动停止服务,我不会收到此消息,因为我的服务和应用程序都不再运行。

在日志文件中,我注意到这种情况发生在 InstallValidate 中,并且我收到此消息 b/c MyApp.exe 正在运行。

我认为发生的情况是:卸载程序检查正在运行的应用程序,它注意到 MyService.exe 和 MyApp.exe 都在运行,检测到 MyService.exe 可能会按照指示由卸载程序本身停止,但不知道关于 MyApp.exe,一旦服务停止,该程序也将被终止,因此它将显示重新启动消息。

我不能直接从卸载程序中关闭 MyApp.exe,因为该服务将再次重新启动它。

如何解决此问题,以便用户在卸载/升级之前无需重新启动或手动停止服务?另外,我无法再更改 MyService 和 MyApp 代码,因此我只能从(卸载)安装程序中执行此操作。

TIA, 维夫

I have a service MyService.exe that is babysitting my application MyApp.exe, meaning it starts the application when this one crashes or whatever. Basically when the service is stopped the application is stopped (by the service) and when the service is started the application is started by the service.

In order to stop my service and by that my application when uninstalling I'm doing:

<ServiceControl Id='MyServiceControl' Name='MyServiceForTest' Start='install' Stop='uninstall' Remove='uninstall'/>

But when I want to uninstall everything I get the error message: "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.". If I manually stop the service before running the uninstaller I don't get this msg as both my service and my application aren't then running anymore.

In the log file I noticed that this happens in InstallValidate and I get this message b/c of MyApp.exe being running.

I think what happens is: the uninstallers checks the running applications, it notices that the MyService.exe and MyApp.exe are both running, detects probably that the MyService.exe will be stopped by the uninstaller itself as instructed, but doesn't know about the MyApp.exe that this one will also be terminated once the service will be stopped so it will show the reboot-message.

I can't just close MyApp.exe from uninstaller b/c the service will restart it again.

How could I solve this problem so that the user won't need to reboot or to manually stop the service before doing an uninstall/upgrade? Also, I can't change MyService and MyApp code anymore so I will have to do this from the (un)installer only.

TIA,
Viv

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

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

发布评论

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

评论(1

故事与诗 2024-09-03 05:31:47

我将在您的服务中公开一种机制,您的安装程序可以在其中指示它停止并终止应用程序。这样,当 Windows Installer 成本计算查找锁定的文件时,它不会找到任何文件。

I would expose a mechanism in your service in which your installer can instruct it to stand down and terminate the application. This way when Windows Installer costing looks for locked files it doesn't find any.

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