Stop windows service before perform the uninstallation

假装没事ソ 提交于 2021-02-20 06:47:05

问题


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.

Error Dialog

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

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

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)!!!

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.

Here is the content of the InstallExecuteSequence Table :

enter image description here

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 posts an error if an in-script custom action is sequenced before the InstallInitialize action or after the InstallFinalize action.

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.


回答1:


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.

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.

Here is the service control view in one Installshield version:

enter image description here



来源:https://stackoverflow.com/questions/18305323/stop-windows-service-before-perform-the-uninstallation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!