PROCESSMONITOR |
Purpose: | Monitor process start or end |
Format: | PROCESSMONITOR [/C [name]] |
PROCESSMONITOR [/=] name STARTED | ENDED | HUNG n command
name | Full pathname of the process to monitor |
n | Number of repetitions (or FOREVER) |
command | Command to execute when condition is triggered |
Usage:
The process name can include wildcards. If you do not include a path for name, PROCESSMONITOR will only compare the filename part of the process names.
The command line will be parsed and expanded before PROCESSMONITOR 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 the last argument on the line is a single (, it is interpreted as the beginning of a command group. PROCESSMONITOR will append the following lines (in a batch file) or prompt you for more input (at the command line) until it gets a closing ).
HUNG will test the process's main window to see if it is still responding to messages. If the process doesn't respond or call GetMessage within 5 seconds, the condition will be triggered. (This is normally only useful for GUI apps.)
If you don't enter any arguments, PROCESSMONITOR will display the processes 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.
PROCESSMONITOR creates three environment variables when a process is STARTED that can be queried by command. The variables are deleted after command is executed.
_processname | The name of the process that was started |
_processpid | The PID of the process |
_processcount | The number of times the command has been triggered |
Example:
If you want to be alerted whenever "myapp" exits:
processmonitor myapp ended forever sendmail [email protected] Myapp Myapp just shut down!
Options: