如何使MSI安装程序在卸载服务时运行一些代码 [英] How to get MSI Installer to run some code on uninstall of a service

查看:240
本文介绍了如何使MSI安装程序在卸载服务时运行一些代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一些麻烦,我想在卸载服务时执行该命令.我已将代码添加到System.ServiceProcess.ServiceProcessInstaller BeforeUninstall事件和
覆盖重写方法OnBeforeUninstall,但这还是行不通的.

I'm having troubles with some could I would like to execute when the service will be uninstalled. I've added the code to both the System.ServiceProcess.ServiceProcessInstaller BeforeUninstall event, and
to the override method OnBeforeUninstall, but that did not work too.

使用我的InstallShield msi卸载服务时,此代码不会执行.

When using my InstallShield msi to uninstall the service this code does not get executed.

如何在卸载过程中强制该服务启动一些代码?我需要在C#服务中使用其他事件吗?我需要更改MSI中的某些内容吗?

How can I force the service to launch some code during uninstall? Do I need to use a different event in my C# service? Do I need to change something in my MSI?

注意: 我的问题与以下相同 https://community.flexerasoftware.com/showthread.php?149176-MSI-Uninstall-NET-Service-does-not-launch-BeforeUninstall-event

Note: My problem is identical to the following https://community.flexerasoftware.com/showthread.php?149176-MSI-Uninstall-NET-Service-does-not-launch-BeforeUninstall-event

谢谢, 萨加尔

推荐答案

您需要更加明确地说明您所做的一切.例如,除非将安装程序类方法作为自定义操作(在您的情况下为卸载自定义操作)显式添加到您的设置中,否则不会自动调用安装程序类方法.您还应该确切说明服务的安装方式.

You'll need to be more explicit about everything you've done. For example there is no automatic calling of installer class methods unless they are explicitly added to your setup as custom actions (in your case an uninstall custom action). You should also explain exactly how the service was installed.

请注意,安装程序类是Visual Studio安装程序发明的,通常无需使用它们,因为InstallShield之类的工具通常支持Windows Installer中的标准ServiceInstall和ServiceControl功能.安装程序类是不必要的.此外,这些事件是Visual Studio的特殊事件,我不清楚InstallShield是否支持它们.如果使用的是Uninstall方法来卸载服务,则只需在Base.Uninstall()调用之前添加"before"代码即可.

Note that installer classes were invented by Visual Studio setups, and there is typically no need to use them because tools like InstallShield usually support the standard ServiceInstall and ServiceControl functionality in Windows Installer. Installer classes are unnecessary. Also, those events are Visual Studio specials, and it's not clear to me if InstallShield supports them. If you are using an Uninstall method to uninstall a service then just add your "before" code to before the Base.Uninstall() call.

如果您希望代码在卸载服务时运行,则更常见的方法是执行一个自定义操作来调用您的代码,并根据REMOVE ="ALL"(用于卸载)或其他条件(取决于您的确切要求.例如,如果您执行升级MSI来升级现有产品,是否仍要运行该卸载代码?

If you want code to run when the service is uninstalled, the more usual way is to have a custom action that calls your code, and condition the call on REMOVE="ALL" (for an uninstall) or other conditions depending on your exact requirement. For example, if you do an upgrade MSI to upgrade your existing product do you still want to run that uninstall code?

这篇关于如何使MSI安装程序在卸载服务时运行一些代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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