WiX MSI install Windows service without starting it

windows-installerwindows-serviceswix

I am trying to create a WiX MSI installer for my Windows service that will install the service, but not start it. I can't seem to find anywhere that explains how to do this or if it's possible.

I tried to remove the ServiceControl I had for starting the service as well as toggling the Start attribute on the ServiceInstall without any luck. It has to be possible to do this, right? I just want the MSI file to install the service and let the user start it when they want.

<Component Id="ServiceInstaller" Guid="9e578e3d-0339-425c-8633-f54ffaaa4921">

    <ServiceInstall Id="ReportingServiceInstaller"
                    Type="ownProcess"
                    Vital="yes"
                    Name="WindowsService.exe"
                    DisplayName="WindowsService"
                    Description="Wickedly awesome and amazing service."
                    ErrorControl="ignore"
                    Account="NT AUTHORITY\LocalService"
                    Start="auto"
                    Interactive="no" />

    <ServiceControl Id="ServiceControl_Stop"
                    Name="WindowsService.exe"
                    Stop="both"
                    Remove="uninstall"
                    Wait="no" />

</Component>

Best Answer

Do not use the ServiceControl element as it is what will start and stop services. By calling it, you are asking the installer to do something with a service. You only need to call ServiceInstall to create a service. As Stefan Wanitzek suggested, you should use demand in the Start attribute of your ServiceInstall. This is to make your service not start running if the user reboots the computer. If your installer is also installing the .exe as welladd the file with the install service. I would suggest to use the following taken from your code:

<Component Id="ServiceInstaller" Guid="3e412e3d-0339-325c-8633-f54ffaaa4921">
        <File Id="WindowsService.exe" 
         Name="WindowsService.exe" 
         KeyPath="yes"
         Source="Path to the EXE"/>
        <ServiceInstall Id="ReportingServiceInstaller"
                Type="ownProcess"
                Vital="yes"
                Name="WindowsService"                    
                DisplayName="WindowsService"
                Description="Wickedly awesome and amazing service."
                ErrorControl="ignore"
                Account="NT AUTHORITY\LocalService"
                Start="demand"
                Interactive="no" />
</Component>
Related Topic