How to install and start a Windows Service under NetworkService account by using WiX?

16,266

Solution 1

First, the message you're getting may be due to a security issue. Your installer must be run by an administrator because creating services requires administrative privileges. You might check for that in a Condition element.

Second, using NT Authority\NetworkService as the account name will fail on non-English systems, because built-in account names are localized. Instead, use plain old NetworkService which Wix recognizes specially and resolves into the correct localized name.

Solution 2

Paul's response is not correct. As per MSDN documentation, to specify the Network Service account, use "NT AUTHORITY\NETWORK SERVICE":

...the name of the account must be

NT AUTHORITY\NETWORKSERVICE

when you call CreateService or ChangeServiceConfig, regardless of the locale...

Set the property "ALLUSERS" to force an Administrator install.

see this link for further information

Solution 3

I've been having this one on Windows 7 and it was bugging me for ages. I fixed it by adding

InstallScope="perMachine"

To my package element:

<Package Description="..."
         Manufacturer="Microsoft Corporation"
         InstallerVersion="200"
         Languages="1033"
         Compressed="yes"
         InstallScope="perMachine"/>
Share:
16,266
Ray
Author by

Ray

Updated on June 13, 2022

Comments

  • Ray
    Ray almost 2 years

    I am trying to create a wix installer to install and start a Windows Service under NetworkService account, but failed, what I got is "Service"() could not be installed. Verify that you have sufficient privileges to install system services."

    Please advice, my code is as below:

    <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>
    

    Thank you!

  • Ray
    Ray over 14 years
    Thank you for replying, would you please let me know how to check for the security issue in Condition element? I am pretty new to wix. I just changed the account name to NetworkService, but the result is still the same. Thank you.