NET START/STOP/PAUSE/CONTINUE

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

Examples:

List the basic Services:

NET HELP SERVICES

List the running Services:

NET START

Stop the print spooler service and if sucessful restart it again:

NET STOP spooler && NET START spooler

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 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 the FIND command as follows:

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

Related:

NET.exe - Manage network resources.
MODE - Configure a system device.
SC - Service Control.
PsService - View and control services.
WMIC SERVICE - WMI access to services.
List of Windows Services
Powershell:
Get-Service - Get a list of services.
New-Service - Create a new service.
Restart-Service - Stop and then restart a service.
Resume-Service - Resume a suspended service.
Set-Service - Change the start mode/properties of a service.
Start-Service - Start a stopped service.
Stop-Service - Stop a running service.
Equivalent bash command (Linux): start-stop-daemon - start and stop system daemon programs.


 
Copyright © 1999-2020 SS64.com
Some rights reserved