English 中文(简体)
WiX uninstaller: restart service if present
原标题:

Part of our app involves registering a plug-in to a third-party product. While the third-party service is running, it has our DLL loaded, so the files on disk are locked.

So when we uninstall our product, we need to begin by stopping the third-party service, and then restart it when we re done with the uninstall. (We also do the same stop/restart thing at install time, because if this is an upgrade, then the existing files are again locked.)

WiX has a command that handles the happy path, no problem:

<ServiceControl Id="SomeUniqueId" Name="NameOfTheirService"
                Start="both" Stop="both"/>

I.e., stop the service at the beginning of both install and uninstall, and restart it at the end of both install and uninstall. So far so good.

The problem comes if the end-user uninstalls the third-party app first, and then tries to uninstall our app. Our app won t work with the third-party service, but if the user wants to uninstall them both, there s nothing to force them to do it in a particular order. However, if the third-party service is no longer installed, then our uninstaller:

  1. Tries to stop the third-party service, fails because the service no longer exists, decides the failure isn t important, and continues.
  2. Uninstalls our product.
  3. Tries to restart the third-party service, fails because the service no longer exists, decides this failure is important, and brings up an error dialog saying, "Service NameOfTheirService (NameOfTheirService) failed to start. Verify that you have sufficient privileges to start system services." (Retry / Cancel)
  4. If the user clicks Retry, goto 3.
  5. If the user clicks Cancel, roll back, and un-uninstall.

In other words, WiX s error handling is wrong. Stopping a service should be failure-tolerant, and it is. Starting a service after install can be failure-intolerant; that s fine: fail my install if the service won t start. But starting a service after uninstall should be failure-tolerant, and it is not.

How can I restart a service after uninstall, without failing the uninstall if that service no longer exists?

问题回答

If you add the Wait attribute to the SeviceControl element and set it to no then as well as "Retry" and "Cancel" you ll also get an "Ignore" button that users can click to continue the Install/Uninstall without having started/stopped the service.





相关问题
3rd party Wix libraries

I am just getting started with Wix. I see there there a several libraries included with the default Wix install. I also see that users can create their own libraries(wixlibs). Are there any 3rd ...

Psake, Powershell & Wix

I have the below function as a part of my psake build. When the build is executing Candle.exe throws this error: candle.exe : warning CNDL1098: ext .BuildPackagesWixWebinWixIIsExtension.dll ...

wix custom dialog for config edit

hi i m trying make a setup msi for my application with wix v3 I have a problem about this task; I need a user input that will be stored in my application s config file (for example i need a dialog for ...

Closing an application using WiX

In creating my WiX installer I have run into an issue when trying to close an application before installing the upgrade. Below is an example of how I am attempting to do this. <util:...

Conditional uninstall of previous version in Wix

I m doing an installer for an software used for debugging embedded ARM cores (OpenOCD) and this installer automatically removes the previous versions - that s simple. However, sometimes that would be ...

热门标签