Windows Command Line – NET


NET

The NET Command is used to manage services as follows:

Syntax
      NET START [service]
      NET STOP [service]
      NET PAUSE [service]
      NET CONTINUE [service] 

Key
   service : The service name as shown in Control Panel, Services

To list the basic Services:

NET HELP SERVICES

To list the running Services:

NET START

Error/return codes

The NET command does not return the documented Win32_Service class return codes (Service Not Active,Service Request Timeout, etc) and for many errors will simply return Errorlevel 2.

It will however echo its own errors on screen:

“The service table is locked. More help is available by typing NET HELPMSG 2180”
“The service table is full. More help is available by typing NET HELPMSG 2181”
“The requested service has already been started. More help is available by typing NET HELPMSG 2182”
“The service name is invalid. More help is available by typing NET HELPMSG 2185”
“The service is not responding to the control function. NET HELPMSG 2186”
“The service control is busy. NET HELPMSG 2187”
“Invalid service program name. NET HELPMSG 2188”
“The service could not be controlled in its present state. More help is available by typing NET HELPMSG 2189”
“The service ended abnormally. More help is available by typing NET HELPMSG 2190”
“The requested pause or stop is not valid for this service. More help is available by typing NET HELPMSG 2191”
“could not find service name. More help is available by typing NET HELPMSG 2192”
“service control dispatcher pipe read failed. More help is available by typing NET HELPMSG 2193”
“A thread for the new service could not be created. More help is available by typing NET HELPMSG 2194”

You can detect these errors by searching the output text with an ‘old school’ FIND command as follows:

NET START alerter 2>&1|FIND “2182”
IF errorlevel 1 goto :sub_already_started

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s