Purpose:Monitor system power changes

 

Format:POWERMONITOR [/C [action]]

POWERMONITOR [Battery | AC | DC | Scheme | Display | Resume | Suspend] [n | FOREVER] command

 

nameFull pathname of the process to monitor
nNumber of repetitions (or FOREVER)
commandCommand to execute when condition is triggered

 

/C(lear)

 

Usage:

 

POWERMONITOR monitors power scheme change, battery power, AC / DC switch, system suspend, and system resume. Note that Windows will send an immediate notification for the current scheme, AC/DC, and battery.

 

The command line will be parsed and expanded before POWERMONITOR 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. POWERMONITOR will append the following lines (in a batch file) or prompt you for more input (at the command line) until it gets a closing ).

 

If you don't enter any arguments, POWERMONITOR 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.

 

POWERMONITOR creates four environment variables on a power change that can be queried by command. The variables are deleted after command is executed.

 

_powerbattery - returns the battery % (0-100).

_powersource - returns the power source (AC or DC).

_powerdisplay - returns 0 if the primary monitor is powered off or 1 if it is on.

_powerscheme - returns the power scheme in use:

0 - Power Saver

1 - Maximum Performance

2 - Balanced

3 - Unknown

 

For example, if you want to be alerted whenever the system switches to DC power:

 

powermonitor DC forever echo just switched to battery power!

 

Options:

 

/CIf name is specified, remove the monitor for that power action. Otherwise, remove all active power monitors.