|
|
| Purpose: | Monitor service start, pause, and / or stop |
| Format: | SERVICEMONITOR [/C [name]] |
SERVICEMONITOR name STARTED | PAUSED | STOPPED n command
| name | Device name |
| n | Number of repetitions (or FOREVER) |
| command | Command to execute when condition is triggered |
Usage:
The service name can include wildcards.
The command line will be parsed and expanded before SERVICEMONITOR is executed, so if you want to pass redirection characters or variables to command you will need to protect them (by enclosing in single back quotes, doubling the %'s, or using command grouping).
If you don't enter any arguments, SERVICEMONITOR will display the services it is currently monitoring.
The monitoring runs asynchronously in a separate thread. When the condition is triggered, the command will be executed immediately. This may cause problems if you try to write to the display or access files while the main TCC thread is also performing I/O. You may need to use START or DETACH in command to avoid conflicts.
SERVICEMONITOR creates several environment variables when a service is started, paused, or stopped that can be queried by command. The variables are deleted after command is executed.
| _servicedisplay | Display name used by service control programs to identify the service |
| _servicename | The name of the service in the service control manager database |
| _servicecount | The number of times the command has been triggered |
| _servicestate | The current state of the service. The possible values are: |
| 1 | The service is stopped |
| 2 | The service is starting |
| 3 | The service is stopping |
| 4 | The service is running |
| 5 | The service continue is pending |
| 6 | The service pause is pending |
| 7 | The service is paused |
Options:
| /C | If name is specified, remove the monitor for that service. Otherwise, remove all service monitors. |