Windows Service Installation with a Service User Account

While installing a windows service I wrote this command in my installation script (not using the installutil.exe) and used a service user account.

 

SC.EXE create MyService binPath= "%CD%MyService.exe" start= auto obj= "domainMyserviceuser" Password= "AbcD12345" DisplayName= "My Service"

SC.EXE DESCRIPTION MyService  "My Alert Service"

NET START MyService

 

During installation I got the below error and the service failed to start though it got installed.

System error 1069 has occurred.

The  service  did not start due to a logon failure.

logon failed due to missing ntrights

When I added the username and password manually to the service and started it manually it worked fine.

Then I modified the installation script and added the following command before creating the service which worked fine in installing and starting the service from the package itself.

ntrights.exe -u Myserviceuser +r SeServiceLogonRight

 

The command ntrights grants the Logon as a service rights to the user.

 

You can find this article in the link BeyondRelational