Using Powercfg.exe in a logon script to configure power management settings

Power Management settings can be set through a logon script using the command line utility powercfg.exe. Powercfg.exe is included with Microsoft Windows XP (SP2), but is not available on earlier versions of Windows (Windows 2000, Windows 98, etc.). It can be used to configure most power options.

In Windows XP, only Local Administrators and Power Users have the rights (by default) to change these settings. It is possible, however, to give members of the Users group enhanced rights to the registry. Adding these rights will also give users rights to change their Power Policies in using Power Options applet in Control Panel.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\
Controls Folder\PowerCfg\PowerPolicies

For more information on editing the registry, see the Microsoft article, How to set or change registry editing permissions in Windows XP or in Windows Server 2003 Exit ENERGY STAR.

Members of the Users group can make these changes by default in Vista, so powercfg.exe can be used in a logon script without any changes.

Below is an example of a batch script for Windows XP that creates a new power scheme using powercfg.exe, sets custom settings for the scheme, and sets it to be the active scheme. An XP workstation has multiple power schemes, each with its own custom settings, but only one can be the active scheme (the one currently being used).

POWERCFG /CREATE Custom1
POWERCFG /CHANGE Custom1 /monitor-timeout-ac 15
POWERCFG /CHANGE Custom1 /monitor-timeout-dc 10
POWERCFG /CHANGE Custom1 /disk-timeout-ac 30
POWERCFG /CHANGE Custom1 /disk-timeout-dc 10
POWERCFG /CHANGE Custom1 /standby-timeout-ac 60
POWERCFG /CHANGE Custom1 /standby-timeout-dc 0
POWERCFG /CHANGE Custom1 /hibernate-timeout-ac 0
POWERCFG /CHANGE Custom1 /hibernate-timeout-dc 30
POWERCFG /CHANGE Custom1 /processor-throttle-ac ADAPTIVE
POWERCFG /CHANGE Custom1 /processor-throttle-dc ADAPTIVE
POWERCFG /SETACTIVE Custom1

In Windows Vista, power schemes are referenced by a GUID. When first installed, the default Power Scheme is the "Balanced" scheme. It has a standard GUID of 381b4222-f694-41f0-9685-ff5bb260df2e, which is the same on every computer. Below is an example of a batch script that duplicates the default balanced power scheme, renames it to Custom1, sets custom settings for the scheme, and sets it to be the active scheme. A Vista workstation has multiple power schemes, each with its own custom settings, but only one can be the active scheme (the one currently being used).

POWERCFG -DUPLICATESCHEME 381b4222-f694-41f0-9685-ff5bb260df2e 381b4222-f694-41f0-9685-ff5bb260aaaa
POWERCFG -CHANGENAME 381b4222-f694-41f0-9685-ff5bb260aaaa "Custom1"
POWERCFG -SETACTIVE 381b4222-f694-41f0-9685-ff5bb260aaaa
POWERCFG -Change -monitor-timeout-ac 15
POWERCFG -CHANGE -monitor-timeout-dc 15
POWERCFG -CHANGE -disk-timeout-ac 30
POWERCFG -CHANGE -disk-timeout-dc 30
POWERCFG -CHANGE -standby-timeout-ac 30
POWERCFG -CHANGE -standby-timeout-dc 30
POWERCFG -CHANGE -hibernate-timeout-ac 0
POWERCFG -CHANGE -hibernate-timeout-dc 0