I ran into a problem on an major upgrade. The installer includes a service and on an upgrade I got a popup saying that a reboot is required to finish the setup process.
To prevent this behaviour I actually just need to stop the service before RemoveExistingProducts
(rather InstallValidate
) is executed.
The MajorUpgrade
is placed after InstallInitialize
and the package has InstallPrivileges="elevated"
.
I have two cases:
Case 1: The service is installed by ServiceInstall
via
<Component Id="myservice_Service" Guid="*">
<File Id="myservice.exe" KeyPath="yes" Vital="yes"
Source="SourceDir\bin\myservice.exe"/>
<ServiceInstall Id="myservice_ServiceInstall" Type="ownProcess"
Vital="yes" Name="myservice" DisplayName="myservice Service"
Description="myservice Service" Start="auto" Account=".\LocalSystem"
ErrorControl="ignore" Interactive="no" Arguments="--run"/>
<ServiceControl Id="myservice_ServiceControl" Name="myservice" Wait="yes" Stop="uninstall"/>
</Component>
The ServiceControl
is not stopping the service before InstallValidate
is called. Even when saying Stop="both". So the popup appears. Note that the service is not started by the installer.
Reasonable posts I've found (excerpt):
- How does one stop a Windows service to do an upgrade install?
- Upgrade a Windows Service without Uninstalling
Case 2: The service is installed by a CustomAction
(there are some reasons why not doing via ServiceInstall
as well).
In this case I have to call an executable to stop the service ("myservice.exe --stop"). For this it's getting tricky, since due to ICE63 it's not allowed to schedule a CustomAction
before RemoveExistingProducts
is called. So, how may I achieve this anyway?
So far I've read posts like:
- WiX call app on uninstall before User prompt "close manually"
- WiX close application before uninstall - close open applications message
- Close a systemtray app before uninstalling using wix
- http://t53456.windows-development-wix-user.wintalk.us/stop-a-service-before-uninstall-t53456.html
A bootstrapper exe is no option, since I need to produce an plain MSI.
I've found similar unanswered problem here: Wix Installer Problem: Why does RestartManager mark Service as RMCritical and not RMService