How to install and start Windows service in NetworkService account using WiX?

I am trying to create a wix installer to install and start a Windows service under the NetworkService account, but it failed that I have a "Service" () which could not be installed. Make sure that you have sufficient privileges to install system services. "

Please advice, my code is as follows:

<Component Id="service" Guid='myguid'> <File Id='JobServiceEXE' Name='JobService.exe' DiskId='1' Source='mypath\JobService.exe' KeyPath='yes' /> <ServiceControl Id="JobService" Name="[SERVICEID]" Stop="uninstall" Remove="uninstall" Wait="yes" /> <ServiceInstall Id="JobService" Name="[SERVICEID]" DisplayName="[SERVICENAME]" Type="ownProcess" Start="auto" ErrorControl="normal" Vital ='yes' Account="NT Authority\NetworkService" Description="Job Service" /> </Component> 

Thanks!

+7
installer windows service wix
source share
3 answers

First, the message you receive may be related to a security issue. Your installer must be run by the administrator because administrative privileges are required to create the services. You can check this in the Condition element.

Secondly, the use of NT Authority\NetworkService , since the account name will not work on non-English systems, since the names of the built-in accounts are localized. Instead, use the plain old NetworkService , which Wix specifically recognizes and resolves to the correct localized name.

+3
source share

Paul's answer is incorrect. According to the MSDN documentation, to specify the network service account, use "NT AUTHORITY \ NETWORK SERVICE":

... account name must be

NT AUTHORITY\NETWORKSERVICE

when you call CreateService or ChangeServiceConfig, regardless of language ...

Set the "ALLUSERS" property to force the administrator to install.

see this link for more information

+17
source share

I had it in Windows 7, and it took me forever. I fixed it by adding

 InstallScope="perMachine" 

To my package element:

 <Package Description="..." Manufacturer="Microsoft Corporation" InstallerVersion="200" Languages="1033" Compressed="yes" InstallScope="perMachine"/> 
+1
source share

All Articles