Stop windows service before perform the uninstallation
Asked Answered
G

1

8

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.

Grande answered 19/8, 2013 at 1:30 Comment(2)
I face the same issue with windows installer in VS2015. How did you get rid off this?Stud
You need to apply the answer below, but because you're using VS installer project, you won't be able to automatically add that row to that table. I'd suggest to create a post-build action to execute -for example- a JScript file that insert that row manually (check #8319420) for a sample row insertionGrande
B
4

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

Baggy answered 4/4, 2014 at 11:6 Comment(1)
This ALMOST worked for me, but there seems to be something missing. IS would install/remove the service, but it couldn't run after being installed like this! When I use my custom install, part of that is providing a class name for the service found inside the exe. There is no argument here for that. (This service is written in Python btw, but converted to an exe with pyInstaller). I could install/uninstall via a CA, but I'm then stuck on the original question posted here!Robbirobbia

© 2022 - 2024 — McMap. All rights reserved.