[wix-users] How do I stop a service during uninstall?

Jason Steenstra-Pickens jason.steenstra-pickens at orionhealth.com
Tue Oct 13 20:45:42 PDT 2015


Hi,

I am using WiX Toolset to create a MSI installer. This installs a Java application which has a native wrapper that gets installed as a service.

I have got this to install fine but when I try and uninstall it the Restart Manager detects files in use and displays a dialog saying that a reboot is required.

The Windows service runs the native wrapper bin\wrapper-windows-x86-64.exe. The component configuration for this is:

    <DirectoryRef Id="bin97543xxxx">
        <Component Guid="cb21cd16-4bb9-4e57-a13c-4d064f01cd43" Id="bin_wrapper_windows_x86_64_exe189026768">
            <File KeyPath="yes" Source="bin\wrapper-windows-x86-64.exe" DiskId="1" Name="wrapper-windows-x86-64.exe" Id="fl_bin_wrapper_windows_x86_64_exe189026768"/>
            <RemoveFile Name="wrapper.log" On="uninstall" Id="rm_fl_bin_wrapper_log123456789"/>
            <ServiceInstall Name="Test App" Description="Test App" Arguments="-s "..\conf\wrapper.conf" wrapper.console.flush=true" Type="ownProcess" Vital="yes" Start="auto" Account="LocalSystem" ErrorControl="ignore" Interactive="no"/>
            <ServiceControl Id="StartService" Name="Test App" Start="install" Stop="both" Remove="uninstall" Wait="yes"/>
        </Component>
    </DirectoryRef>
This native wrapper will launch the JVM java.exe with some other JARs and native DLLs. These JARs and DLLs are defined as separate components such as:

    <DirectoryRef Id="bin_wrapper_lib172428748">
        <Component Guid="91ea3118-769e-4100-80a2-f09a586500a5" Id="bin_wrapper_lib_wrapper_jar565349582">
            <File Source="bin\wrapper\lib\wrapper.jar" DiskId="1" Name="wrapper.jar" Id="fl_bin_wrapper_lib_wrapper_jar565349582"/>
        </Component>
    </DirectoryRef>
When I try and uninstall the program it detects files in use by java.exe even though when the service stops it will stop the JVM. I have verified this by manually stopping the service before trying to uninstall. Also to note is that if I continue then all the files are removed succesfully, just the Windows service is still there (but marked as deleted). The MSI logs show this:

Action start 15:48:40: InstallValidate.
...
MSI (s) (AC:68) [15:48:40:424]: RESTART MANAGER: Detected that application with id 3636, friendly name 'java.exe', of type RmCritical and status 1 holds file[s] in use.
MSI (s) (AC:68) [15:48:40:424]: RESTART MANAGER: Did detect that a critical application holds file[s] in use, so a reboot will be necessary.
...
MSI (s) (AC:68) [15:48:59:078]: RESTART MANAGER: The user chose to go on with the installation, although a reboot will be required.
...
The setup must update files or services that cannot be updated while the system is running. If you choose to continue, a reboot will be required to complete the setup.
I've seen some similar questions on SO and the WiX Toolset users mailing list but nothing that really helps. A lot of people are trying to use custom actions and have been told to use the ServiceControl instead which I am already using.

I also saw someone mention the "files in use logic" which I assume is what the Restart Manager is doing. There was a suggestion to add the related files into the component with the ServiceControl element but that doesn't seem right here (or at least I'm not sure how to do it and still follow the best practices around separating components).

Can anyone point me in the right direction?


Cheers


More information about the wix-users mailing list