What’s the best way to start/stop a windows service before install/uninstall?

I currently have a bootstrapper wix project that contains two msi projects. I’m trying to figure out the best way to do the following on installation/uninstallation/modify/repair.

  1. Prompt user that the proceeding will restart a critical windows service
  2. If no is selected, abort installer
  3. If yes is selected, stop service
  4. Run through the appropriate sequence to install/uninstall/etc with all the msi files in the chain
  5. Once the chain of msi files is complete, start the windows service again.

It seems a custom action is in order (in each msi project) however I have yet to figure out the best way to only show the confirmation prompt one time (instead of once per msi) and also how to ensure the first msi doesn’t restart the windows service and that the last msi does restart the windows service.

Essentially both msi projects require that a windows service be stopped before installation/uninstallation/etc although it should be restarted when the installer is complete. Ideas?

That seems really complicated. I’d let each MSI stop/start the services as needed during the installation. If it is really important the service is only stopped/started once, then I’d extract it into a separate package.

You can probably do what you’re trying to do, but it will be far more fragile than one of the options I proposed.

Leave a Comment