在执行卸载之前停止Windows服务 [英] Stop windows service before perform the uninstallation

查看:51
本文介绍了在执行卸载之前停止Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装程序,用于安装包括Windows服务在内的一些组件,安装后,它将启动使用CustomAction安装到系统上的服务.

I have an installer that installs few components including windows service, after it installed it'll start the service that installed onto the system using CustomAction.

当我卸载应用程序时出现问题,安装程序会要求先关闭应用程序,然后再继续.

The problem when I uninstall the application, the installer asks to close the application before continue.

我创建了一个将停止服务的自定义操作,并通过卸载"操作对其进行了安排.

I created a custom action that will stop the service, and I scheduled it with Uninstall actions.

但是直到手动停止服务后,我在错误对话框中按OK才执行该操作.

But its not executed until I press OK for the error dialog after manually stop the service.

它在Win7上失败,但是我在WinXP上测试了相同的MSI并正常工作(在检查文件正在使用"之前执行了自定义操作)!

It failed on Win7, but I tested the same MSI on WinXP and worked fine (The custom action executed before checking the file In-use)!!!

我正在使用VS2010安装程序项目来创建安装程序,但是在构建后(例如使用Orca)对其进行修改没有问题.

I'm using VS2010 setup project to create the installer, but I don't have problem to modify it (using Orca for example) after build.

这是InstallExecuteSequence表的内容:

Here is the content of the InstallExecuteSequence Table :

我发现用于检查使用中文件的InstallValidate 操作,但是我无法对在该服务之前停止该服务的自定义操作进行排序,因为该服务在 ICE77评估程序)

I found that the InstallValidate action that check for In-Use files, but I can't sequence my custom action that stop the service before it because its before InstallInitialize action that require all custom actions to be after it (ICE77 Evaluator)

如果在脚本自定义操作之前对ICE77进行了排序,ICE77将发布错误InstallInitialize操作或在InstallFinalize操作之后.

ICE77 posts an error if an in-script custom action is sequenced before the InstallInitialize action or after the InstallFinalize action.

我应该怎么做,我应该使用 MSIRESTARTMANAGERCONTROL 属性,用于指定Windows Installer程序包是否使用FilesInUse对话框功能,但我需要将其他正在使用的文件通知用户.

What should I do, shall I use the MSIRESTARTMANAGERCONTROL property that specifies whether the Windows Installer package uses the FilesInUse Dialog functionality, but I need to notify the user about the other in-use files.

推荐答案

Windows Installer中具有内置功能-无需自定义操作.实际上,除非您的服务非常特殊,否则我强烈建议您不要使用自定义操作(例如,停止速度慢,或者需要关闭大量资源,并且需要验证是否这样做).大多数正常服务会在半分钟左右的时间内停止.我不确定将Windows Installer引擎配置为等待服务停止的时间.

There are built-in features for this in Windows Installer - no custom action necessary. In fact I would strongly advice against using a custom action for this unless your service is very special (for example, slow to stop, or in need of shutting down a lot of resources and you need to verify that it does so). Most normal services stop within half a minute or so. I am not sure how long the Windows Installer Engine is configured to wait for the service to stop.

ServiceControl表 是其幕后"功能.大多数安装工具都提供类似向导或GUI的元素,以更简单的方式对其进行控制.

The ServiceControl table of MSI is the "under the hood" feature for this. Most installation tools provide wizard like or GUI elements to control this in a simpler fashion though.

这是一个Installshield版本的服务控制视图:

Here is the service control view in one Installshield version:

这篇关于在执行卸载之前停止Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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