Friday, August 20, 2010

Start or stop Windows service from command line

REF: http://www.windows-commandline.com/2010/08/start-stop-service-command-line.html

We normally use Services.msc to start or stop or disable or enable any service. We can do the same from command line also using net and sc utilities. Below are commands for controlling the operation of a service.

To stop a service from command prompt:

net stop servicename

To start a service from command prompt:

net start servicename

To disable a service from command prompt:

sc config servicename start= disabled

To reenable a service from command prompt:

sc config servicename start= demand

To make a service automatic from command prompt:

sc config servicename start= auto


Note: Space is mandatory after '=' in the above sc commands

Add user to group from command line

We can add users to a group from command line too. We can use net localgroup command for this.

For example to add user John to administrators group we can run the below command.

net localgroup administrators John /add


REF:http://www.windows-commandline.com