Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a batch file that installs a Windows service. The service needs to run under a specific user account. Does anybody know how to set the user account through the batch file instead of using the Windows "Services" GUI?

share|improve this question
up vote 4 down vote accepted

To change an existing service, use the sc config command. To change the "foo" service to use the "DOMAIN\User" credential with the password "password", execute:

sc config foo obj= DOMAIN\User password= password

Be sure to put spaces between the equals signs and the arguments.

If you're using sc create to create the service just add the obj= and password= arguments and you're done.

share|improve this answer
Thanks. This really helped me. – user36540 Jun 23 '10 at 3:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.