How to start/stop services from the command line

To start a service: net start <service_name>

To stop a service: net stop <service_name>

To get the list of services installed on the computer, open the registry (use regedit) and navigate to HKLM/System/CurrentControlSet/Services. In there you can see the list of services: one entry per key.

If you want to restart a service from a batch file, you have to wait before restarting it as it can take some time to stop a service and the net stop call is not blocking. You can use the following to restart the DNS Client service for example:

:start
net start Dnscache
if not errorlevel 0 goto start

This is a crude example, it will loop indefinitely if the service fails to start for an unkown reason.

For other registry tips for french readers: Astuces Regedit

Advertisements
This entry was posted in Windows and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s