This command confirms the status of services in batch files to start up/stop services.
Synopsis
chksrv service name {start|stop}
Operands
service name
Specify the name of service whose status is to be confirmed.
start
Specify to check whether the service has started or not.
stop
Specify to check whether the service has stopped or not.
Return Values
Return value | Meaning |
---|---|
0 | When "start" operand is specified, this indicates the service has started. When "stop" operand is specified, this indicates the service has stopped. |
10 | When "start" operand is specified, this indicates the service has not started. When "stop" operand is specified, this indicates the service has not stopped. |
20 | The service is in the process of startup. |
30 | The service is in the process of stopping. |
40 | The service is in the process of resuming. |
50 | The service is in the process of pausing. |
60 | The service has paused. |
-1 | Another error has occurred. |
Standard Output
When executing the chksrv command, the following character strings are logged to the standard output (stdout).
When a service has started running : | SERVICE_RUNNING |
When a service has stopped : | SERVICE_STOPPED |
When a service is in the process of startup : | SERVICE_START_PENDING |
When a service is in the process of stopping : | SERVICE_STOP_PENDING |
When a service is in the process of resuming: | SERVICE_CONTINUE_PENDING |
When a service is in the process of pausing: | SERVICE_PAUSE_PENDING |
When a service has paused: | SERVICE_PAUSED |
Examples
The example of use in batch file is shown below:
An example of a batch file that starts services
If the upper limit value for normal completion code of job is 0, the batch file shown below terminates normally when services have started running (completion code is 0), while the batch file terminates abnormally when services have not started running (completion code is 10).
net start service name chksrv service name start
An example of a batch file that stops services
If the upper limit value for normal completion code of job is 0, the batch file shown below terminates normally when services have stopped (completion code is 0), while the batch file terminates abnormally when services have not stopped (completion code is 10).
net stop service name chksrv service name stop