Configuring Windows services using Command Prompt

Configuring the properties of a Windows Service using command prompt and scripting it in a batch file is really simple and can save you from performing the same manual configuration again and again.

The sc utility comes handy to achieve this.

In the example below, we are going to configure a windows service to:

  • Set the startup type as automatic.
  • Run the service under a particular account
  • Set the failure actions for the service and set the reset period.
  • Define dependencies.

To give a more clear understanding, screenshots of the service properties UI is attached along with the scripts to set the configurations.

1. Set the startup type as automatic.


sc config "Service1"  start= auto

Note here that although the Display name of the Service is myfirstservice, The actual Service name is Service1. We need to use the actual service name in the scripts to control the service properties.

2. Run the service under a particular account


sc config "Service1" obj= mydomain\sidharth password= MyPassword


3.Set the failure actions for the service and set the reset period.


sc failure "Service1"  actions= restart/180000/restart/180000/""/180000 reset= 86400

The restart service times are in milliseconds and the reset fail count time is in seconds.

4. Define dependencies.


Our service depends on the SQL Server service, whose Actual Service name is MSSQLServer, To set this dependency, use the following command.

sc config "Service1"  depend= "MSSQLServer"

Finally, to start the server use

net start Service1

We can also club all the command and save it as a batch file, it will look like this:

sc config "Service1"  start= auto
sc config "Service1" obj= mydomain\sidharth password= MyPassword
sc failure "Service1"  actions= restart/180000/restart/180000/""/180000 reset= 86400
sc config "Service1"  depend= "MSSQLServer"
net start Service1

Comments (14)

  1. Alex says:

    I desire that the service is activated with a local account and not with a particular account, which would be the syntax to follow?

    Thank you!


  2. Alex,

    Use this syntax:

    sc config "Service1" obj= "localsystem"


  3. Alex says:

    thank you very much Sidharth for your quick response …

    I tried it with this syntax, but I get an following error :

    [SC] ChangueServiceConfig FAILED 1057

    I hope you can help me …

  4. Alex,

    It must be giving a detailed description of failure also. Can you please check and send it across. Make sure there is no space in localsystem, copy the above snippet as it is and replace Service1 by your service name.

  5. Alex says:

    I substituted Service1 by the name of my service, and LocalSystem has no spaces, I really do not know the cause of this error.


  6. Alex says:

    I have not managed to correct the mistake … you have some idea of the cause or possible solution?

  7. Alex says:

    the full error message is:

    [SC] ChangueServiceConfig FAILED 1057

    the account name is invalid or does not exist or the password is invalid for the specified account name

    Alex Moreno

  8. Alex says:

    already solved the problem, I had to add the sentence empty password …

    password = ""

    Thank you!

  9. Thats Great 🙂

    For me it works fine even without specifying the password. We both seem to be running different versions of OS.

  10. JCB says:

    You should use this command when changing back to Local System:

    sc config "servicename" obj= LocalSystem password= LocalSystem

  11. jlvazquez says:

    Do blank passwords work for NON LocalSystem users?

    I need to install a JBoss service as the current logged used on a Windows XP Professional.

    I set the user and password with this command in my automated install BAT script:

    sc config RFBCAJAJBOSS obj= ".%USERNAME%" password= ""

    %USERNAME% has a blank password and does autologon on the PC

    I also set the registry key to allow for blank passwords on services:




    – The user is set correctly on the service, but the password is either ignored or changed by something else (non blank) because after running my install.BAT the service DOES NOT START.

    – You have to MANUALLY go to the Services control panel (under Start-> Control Panel -> Sys admin tools -> Services) and select the login tab ensuring to set a blank password for the user.

    Is there anyway to automate this and avoid the installation process to include this "manual password blanking" step?

  12. Allan says:

    sc config SQL Server (MSSQLSERVER) obj= .username password= password type= own

    tells me the service does not exist but all other 7 services do work, i have tried it with and with out the quotation marks.

    please Help me !!

  13. Hi Allan,

    You have to use the Service Name (can be obtained by right clicking the service > properties > Service name). For you, it will be MSSQLSERVER, so the following command should work:

    sc config "MSSQLSERVER" obj= .username password= password



Skip to main content