How to install and start a Windows Service using WiX
The following code works for me... no need to prompt for username/password :)
<File Id='JobServiceEXE' Name='JobService.exe' DiskId='1' Source='JobService.exe' KeyPath='yes'/>
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Name="JobService"
DisplayName="123 Co. JobService"
Description="Monitoring and management Jobs"
Start="auto"
Account="[SERVICEACCOUNT]"
Password="[SERVICEPASSWORD]"
ErrorControl="normal"
/>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="JobService" Wait="yes" />
</Component>
I found the solution on this page would install the service correctly but that the ServiceControl element would not start the service.
Comparing the wix installed service with manual installed service ("JobService.exe /install"), the "Path to executable" field was missing a start switch. Fixed this in wix with the arguments attribute of ServiceInstall;
<File Id='JobServiceEXE' Name='JobService.exe' DiskId='1' Source='JobService.exe' KeyPath='yes'/>
<ServiceInstall
Id="ServiceInstaller"
Type="ownProcess"
Name="JobService"
DisplayName="123 Co. JobService"
Description="Monitoring and management Jobs"
Start="auto"
Account="[SERVICEACCOUNT]"
Password="[SERVICEPASSWORD]"
ErrorControl="normal"
Arguments=" /start JobService"
/>
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="JobService" Wait="yes" />
</Component>
A long time lurker, this is my first post on here - I hope it helps someone.