Can't start Windows service with WiX
I had the same issue using WiX 3.7.821.0 and my service. It installed for a while and the same annoying "Service failed to start. Verify that you have sufficient privileges to start system services" appeared.
I tried a lot, but the final thing was to use two sections for <ServiceControl>
instead of trying to cram all in a single one. One for Start and one for Stop. Now the service starts fine.
This does not work:
<ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="MyService" Wait="yes" />
This works:
<ServiceControl Id="ServiceControl_Start" Name="MyService" Start="install" Wait="no" /><ServiceControl Id="ServiceControl_Stop" Name="MyService" Stop="both" Remove="uninstall" Wait="yes" />
I have been looking for the answer for a while, and finally I've resolved it!
Keep the same ServiceControl name as the ServiceInstall name.
Result:
<?xml version="1.0" encoding="utf-8"?><?define ProductVersion = "1.0.0"?><?define ProductUpgradeCode = "{E8DFD614-41F6-4592-AD7A-27EA8A49C82E}"?><Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> <Product Id="*" UpgradeCode="$(var.ProductUpgradeCode)" Name="Eyes Relax" Version="$(var.ProductVersion)" Manufacturer="Ourdark" Language="1033"> <Package Manufacturer="Ourdark" InstallerVersion="100" Languages="1033" Compressed="yes" /> <Media Id="1" Cabinet="WHSDiskManagement.1.1.0.0.cab" EmbedCab="yes" /> <Property Id="WHSLogo">1</Property> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder" Name="PFiles"> <Directory Id="WHS" Name="Eyes Relax"> <Component Id="EyesRelax" Guid="{78534F5E-FC72-49E6-AF11-4F2068EA7571}"> <File Id="RelaxEyes.exe.config" Name="RelaxEyes.exe.config" Source="RelaxEyes\bin\Debug\RelaxEyes.exe.config" Vital="yes" KeyPath="no" DiskId="1"/> <File Id="RelaxEyes.exe" Name="RelaxEyes.exe" Source="RelaxEyes\bin\Debug\RelaxEyes.exe" Vital="yes" KeyPath="yes" DiskId="1"/> <ServiceInstall Id="ServiceInstaller" Type="ownProcess" Vital="yes" Name="Eyes Relax" DisplayName="Eyes Relax" Description="Eyes Relax" Start="auto" Account="NT AUTHORITY\LocalService" ErrorControl="ignore" Interactive="no"> </ServiceInstall> <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="Eyes Relax" Wait="yes" /> </Component> </Directory> </Directory> </Directory> <Feature Id="ProductFeature" Title="WHSDiskManagement" Level="1"> <ComponentRef Id="EyesRelax" /> </Feature> </Product></Wix>
I had the same error, and in my case I was missing KeyPath='yes' Vital="yes"
on my file element.
Here is my component definition:
<Component Id="ComponentName" Guid="3aa1d5a5-28f0-4753-8e4b-a7ac0848d8be" > <File Id='ServiceFile' Name='Service.exe' DiskId='1' Source='bin\Service.exe' KeyPath='yes' Vital="yes"/> <ServiceInstall Id="ServiceInstaller" Type="ownProcess" Name="Service" DisplayName="Service" Description="A Service" Start="auto" ErrorControl="normal" /> <ServiceControl Id="ServiceControl" Start="install" Stop="both" Remove="uninstall" Name="Service" Wait="yes" /></Component>