SetSystemState( )

Action: Changes the (power) state of the computer.
 
Syntax: SetSystemState (mode, force)
 
Parameters: Type

Optional parameter specifying one of the following modes:

Value

Meaning

0

Lock system (only supported on Windows 2000 or newer)

1

Standby

2

Hibernate

3

Power Off

Force

Specifies whether applications with unsaved changes are forcibly closed. If force is not zero, applications are closed. If force is zero, a dialog box is displayed prompting the user to close the applications.

Returns:
0 Function succeeded
Error code Function failed  
 
Example:

; Force system to standby mode
$rc = SetSystemState(1,1)