AHS
AHS

Reputation: 784

Logon failure in running a windows service

I am running a service called prunner on windows server 2012. I used the command sc to change the username and the password of the service:

sc.exe config myService obj= "sqa265\hero" password= "hero1"

The output of the command is saying that it have succeed but when I go to task manager in order to start the service I get: logon failure!!!

I tried to run the sc command under the user hero and under the user administrator but I still get the same error. But the very strange thing is that if I do the same thing manually via the task manager and service control pane I success and the service go to the state:running!!! But I need to automate this thing, so please any help?

Upvotes: 3

Views: 4576

Answers (1)

Charles
Charles

Reputation: 61

You need to give the account "sqa265\hero" the SeServiceLogonRight permission. As you have noticed setting the credentials up through the control panel works, but what you might not have noticed is that if you tried to use the command line after using the control panel.

You can test this by setting the service back to the Local System account in the control panel, and then running your command-line again.

To fix this from a script, you can use the NTRights utility outlined in this MS knowledgebase article: http://support.microsoft.com/kb/315276

After you install NTRights, you can run it like this:

NTRights.exe +r SeServiceLogonRight -u "sqa265\hero"

Combined with the sc config commandline you already have, the service should run with those credentials.

Further reading: http://www.techrepublic.com/article/set-user-rights-using-the-ntrights-utility/5032903

Upvotes: 6

Related Questions