Script to configure an existing service to run with a different account

Does anyone have a script that will configure an existing service running on a PC to use a different user account other than the local system account? Here is an example to put it into context:

SERVER1 (Windows Server 2003) currently has a Service running called 'Service1' which is running as the "log on as" user account of local system. This Service needs to be reconfigured so that the "log on as" user account is '' with the password of 'password'.
Who is Participating?
oBdAConnect With a Mentor Commented:
You can do that with sc.exe (even remotely; for local execution, just drop the "\\server1").
sc \\server1 config Service1 obj= password= password
Things worth noting:
* Note spaces after the equal signs in "obj=" and "password="!
* I'm not completely sure whether sc understands the UPN syntax and can't test it at the moment. If it doesn't work, use YOURNETBIOSDOMAINNAME\srvrun instead of
* Don't use characters in the password that have special meaning in the command line: | < > % ^ & " ( )
dont think thats possible!
But u can start the service with specified credentials!

runas /user yourdomain\youraccount net start messenger
note the differences between starting a service and running a service!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.