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

Posted on 2007-08-05
Last Modified: 2013-11-05
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'.
Question by:Retrovertigo
    LVL 31

    Expert Comment

    dont think thats possible!
    But u can start the service with specified credentials!

    runas /user yourdomain\youraccount net start messenger
    LVL 31

    Expert Comment

    note the differences between starting a service and running a service!
    LVL 82

    Accepted Solution

    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: | < > % ^ & " ( )

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
    In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now