3

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?

4

1 回答 1

1

如果将Wait属性添加到SeviceControl元素并将其设置为no then 以及“Retry”和“Cancel”,您还将获得一个“Ignore”按钮,用户可以单击该按钮以继续安装/卸载而无需启动/停止服务。

于 2009-12-03T22:03:41.930 回答