Search code examples
wixwindows-installer

Installer stopping service and giving file in use warning


I have a WiX installer project which installs a client app and a windows service. It is set to stop the service during install. However it still shows the error window:

The following applications are using files which the installer must update

with the Try Again, Continue and Cancel options. If I choose Continue and inspect the windows event logs for the installer it shows the service being stopped and started again. The StopServices element is in the recommended sequence position.

How can I avoid the error window?

My understanding is that it doesn't matter what order the files are listed as windows installer stops the service before copying any of them. I had wondered whether the service exe needed to be listed first.


Solution

  • Best solution: Use the "ServiceInstall" and "ServiceControl" elements to ensure the service is stopped/started (and installed/uninstalled) correctly.

    In fact in our installer the app and service were being stopped/started from within custom installer code. However the check for whether the files are in use occurs before the custom installer code is run. So the files are in use when the installer starts, but are not in use by the time the installer attempts to copy the files. So annoying to the user, but not actually an issue. And if installed using msiexec.exe in quiet mode then the install succeeds.

    Furthermore we had another issue with the service returned from the shutdown call, prior to actually having shutdown. (As commented by @PhilDW).