问题
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.
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 :
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:
来源:https://stackoverflow.com/questions/18305323/stop-windows-service-before-perform-the-uninstallation