如何使用 MSI 软件包卸载顶级服务? [英] How do you uninstall a topshelf service with an MSI package?

查看:47
本文介绍了如何使用 MSI 软件包卸载顶级服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个使用 topshelf 开发的服务,这些服务是使用在 InstallShield 中创建的 MSI(使用基本 MSI)安装的.我们使用传递安装参数的自定义操作来安装它们.在卸载时,我们使用传递卸载参数的自定义操作(我们也有根据需要启动和停止的自定义操作).所有这些都在工作,但是用户会看到一个对话框,要求他们关闭这些服务,否则可能需要重新启动.但是,如果用户选择继续,我们的自定义操作就会运行,停止并卸载服务.

I have several services developed with topshelf that are installed using an MSI created in InstallShield (using basic MSI). We install them using a custom action passing the install parameter. When it comes to uninstall, we use a custom action passing the uninstall parameter (we also have custom actions that start and stop as appropriate). All of this is working, but the user is presented with a dialog asking them to shut down those services otherwise a reboot may be required otherwise. If, however, the user elects to continue anyway, our custom action runs, stopping and uninstalling the service.

我一直无法在执行序列中将停止操作移到足够高的位置,以避免在不导致不在事务中错误的情况下出现对话框.

I have been unable to move the stop action high enough in the execute sequence to avoid the dialog without causing a not in transaction error.

有什么办法可以摆脱那个对话框吗?

Is there some way I can get rid of that dialog?

推荐答案

要使用自定义操作停止服务,您需要在 InstallValidate 之前拥有它,这意味着它必须是即时的,因此如果安装会变得棘手被取消或失败,因为这样您将在停止服务的情况下离开系统.

To stop the service with a custom action you'd need to have it before InstallValidate, which means it has to be immediate, so it gets tricky if the install is canceled or fails because then you leave the system with a stopped service.

真正的解决方案是您应该使用 ServiceInstall 元素安装服务,并使用 ServiceControl 元素停止/启动/删除它们.卸载时,如果 Windows Installer 发现您将停止该服务(使用 ServiceControl),则它不会执行 FilesInUse 对话框.

The real solution to this is that you're supposed to install services with the ServiceInstall element, and stop/start/delete them with the ServiceControl element. At uninstall, if Windows Installer sees that you're going to stop the service (with ServiceControl) then it doesn't do a FilesInUse dialog.

所以简短的回答是您可能根本不需要自定义操作.ServiceControl 元素可用于停止和启动所有服务(不仅仅是使用 ServiceInstall 安装的服务),因此如果您执行 ServiceControl 元素以在卸载时停止服务,它可能会解决问题.从长远来看,我会远离命令行安装并使用 ServiceInstall.

So the short answer is that you may not need a custom action at all. The ServiceControl element can be used to stop and start all services (not just ones being installed with ServiceInstall) so if you do a ServiceControl element to stop your service at uninstall it might solve the problem. In the long term I'd get away from command line installs and use ServiceInstall.

这篇关于如何使用 MSI 软件包卸载顶级服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆