Bart's Weblog

Just a blog…

Powercfg.exe utility

Posted by bartvdw on 2626/0101/2008

Today I discovered a very nice utility: powercfg.exe

Reason was that I received the question for force a specific power scheme on clients, namely monitor should go to standby after 30 minutes. Client OS is Windows XP, no GPO settings found to accomplish the task. Then I found the powercfg.exe utility. Adding this is a simple script with some standard schemes (.pow files) solved my issue forever!

Works perfectly on Windows XP & Windows Server 2003…

Edit: GPP extends power settings if you’re capable using them…

How to use Powercfg.exe in Windows Server 2003
http://support.microsoft.com/kb/324347

POWERCFG [/LIST | /QUERY [name] | /CREATE name | /DELETE name |
       /SETACTIVE name | /CHANGE name settings |
       /HIBERNATE {ON|OFF} | /EXPORT name [/FILE filename] |
       /IMPORT name [/FILE filename] | /GLOBALPOWERFLAG {ON|OFF} /OPTION flag |
       /BATTERYALARM {LOW|CRITICAL} [settings] |
       /DEVICEQUERY queryflags | /DEVICEENABLEWAKE devicename |
       /DEVICEDISABLEWAKE devicename | /?]

Description:
    This command line tool enables an administrator to control
    the power settings on a system.

Parameter List:
    /LIST, /L       Lists the names of existing power schemes.
    /QUERY, /Q      Displays the configuration of the specified power scheme.
                    If no name is specified, the configuration of the currently
                    active power scheme is displayed.
    /CREATE, /C     Creates a power scheme with the specified name.  The new
                    scheme is created with the properties of the currently
                    active scheme.
    /DELETE, /D     Deletes the power scheme with the specified name.
    /SETACTIVE, /S  Makes the power scheme with the specified name active.
    /CHANGE, /X     Changes settings of the specified power scheme. Additional
                    switches specify the changes as follows:
                        /monitor-timeout-ac <minutes>
                        /monitor-timeout-dc <minutes>
                        /disk-timeout-ac <minutes>
                        /disk-timeout-dc <minutes>
                        /standby-timeout-ac <minutes>
                        /standby-timeout-dc <minutes>
                        /hibernate-timeout-ac <minutes>
                        /hibernate-timeout-dc <minutes>
                        /processor-throttle-ac <throttle>
                        /processor-throttle-dc <throttle>
                    AC settings are used when the system is on AC power.
                    DC settings are used when the system is on battery power.
                    Setting a timeout to zero will disable the corresponding
                    timeout feature.  Supported throttle settings are NONE
                    CONSTANT, DEGRADE, and ADAPTIVE.
    /EXPORT, /E     Exports the power scheme with the specified name to a
                    file.  If no filename is specified, the default is
                    SCHEME.POW.  This additional parameter is supported:
                        /FILE <filename>
    /IMPORT, /I     Imports the power scheme from a file under the specified
                    name.  If no filename is specified, the default is
                    SCHEME.POW.  If a scheme with that name already exists, it
                    is replaced with the new one.  This additional parameter
                    is supported:
                        /FILE <filename>
    /HIBERNATE, /H {ON|OFF}  Enables/Disables the hibernate feature.  Hibernate
                    timeout is not supported on all systems.
    /NUMERICAL, /N  Allows the power scheme to be operated upon to be specified
                    using a numerical identifier.  When using this switch, in
                    place of the name of the power scheme on the command line,
                    specify its numerical identifier.  This switch may be used
                    in combination with the /QUERY, /DELETE, /SETACTIVE,
                    /CHANGE, /EXPORT, and /IMPORT commands.
    /GLOBALPOWERFLAG, /G {ON|OFF}  Turns one of the global power flags on/off.
                    Valid flags (to be used after "/OPTION ") are:
                         BATTERYICON:    Turns the battery meter icon in the
                                         system tray on/off.
                         MULTIBATTERY:   Turns on/off multiple battery display
                                         in system Power Meter.
                         RESUMEPASSWORD: Prompt for password on resuming the
                                         system.
                         WAKEONRING:     Turn on/off wake on ring support.
                         VIDEODIM:       Turn on/off support for dimming video
                                         display on battery power.
    /AVAILABLESLEEPSTATES, /A  Reports the sleep states available on the
                    system.  Attempts to report reasons why sleep states are
                    unavailable.
    /BATTERYALARM, /B {LOW|CRITICAL}  Configures the battery alarm.  The
                    following switches can be specified:
                        /activate <on|off>
                            Enables or disables the alarm.
                        /level <percentage (0 – 100)>
                            The alarm will be activated when the power level
                            reaches this percentage.
                        /text <on|off>
                            Turns the text notification on or off.
                        /sound <on|off>
                            Turns the audible notification on or off.
                        /action <none|shutdown|hibernate|standby>
                            Specifies the action to take when this alarm goes
                            off.  Not all actions are always available.
                        /forceaction <on|off>
                            Force stand by or shutdown even if a program stops
                            responding.
                        /program <on|off>
                            Specifies a program to run.  schtasks.exe /change
                           may be used to configure the program.
    /DEVICEQUERY <queryflags> will return a list of devices that meet the
                    criteria specified in <queryflags>.  Possible values
                    for <queryflags> are:
                    wake_from_S1_supported – return all devices that support
                             waking the system from a light sleep state.
                    wake_from_S2_supported – return all devices that support
                             waking the system from a deeper sleep state.
                    wake_from_S3_supported – return all devices that support
                             waking from the deepest sleep state.
                    wake_from_any – return all devices that support waking
                             from any sleep state.
                    S1_supported – list devices supporting light sleep states.
                    S2_supported – list devices supporting deeper sleep.
                    S3_supported – list devices supporting deepest sleep.
                    S4_supported – list devices supporting system hibernation.
                    wake_programmable – list devices that are user-configurable
                             to wake the system from a sleep state.
                    wake_armed – list devices that are currently configured to
                             wake the system from any sleep state.
                    all_devices – return all devices present in the system.
                    all_devices_verbose – return verbose list of devices.
    /DEVICEENABLEWAKE <devicename> enable the device to wake the system from a
                    sleep state. <devicename> is a device retrieved using
                    the ‘/DEVICEQUERY wake_programmable’ parameter.
    /DEVICEDISABLEWAKE <devicename> disable the device from waking the system
                    from a sleep state. <devicename> is a device retrieved
                    using the ‘/DEVICEQUERY wake_armed’ parameter.
    /HELP, /?       Displays information on command-line parameters.

Examples:
    POWERCFG /LIST
    POWERCFG /QUERY scheme
    POWERCFG /QUERY
    POWERCFG /CREATE scheme
    POWERCFG /DELETE scheme
    POWERCFG /SETACTIVE scheme
    POWERCFG /CHANGE scheme /monitor-timeout-dc 15
    POWERCFG /CHANGE scheme /monitor-timeout-dc 0
    POWERCFG /HIBERNATE on
    POWERCFG /EXPORT scheme /file file
    POWERCFG /QUERY number /NUMERICAL
    POWERCFG /GLOBALPOWERFLAG on /OPTION BATTERYICON
    POWERCFG /AVAILABLESLEEPSTATES
    POWERCFG /BATTERYALARM low
    POWERCFG /BATTERYALARM critical /ACTIVATE on /LEVEL 6 /ACTION hibernate
    POWERCFG /DEVICEQUERY wake_armed
    POWERCFG /DEVICEENABLEWAKE "Microsoft USB IntelliMouse Explorer"

Advertisements

16 Responses to “Powercfg.exe utility”

  1. andrein2000 said

    Yes, it does solve a problem for user using Administrators Privilege, but for another user with limited privilege it doesn’t work as well.

    Could you imagine, you have hundreds of PC’s on your domain with Users privillege only and need to deploy that power scheme.

    But since Windows has darn restriction on its power scheme, you must change/leverage user privilege manualy on each hundreds of PC to have an Administrators Privilege… :((

    It is so much annoying since you can’t just send batch files contains that power scheme by mail to every users in domain due to the limitation that windows has.

    Is there anyone has a better solution for this issue ?….

  2. bartvdw said

    Yes there is a better solution: Group Policy Preferences.
    http://blogs.technet.com/askds/archive/2008/03/21/managing-power-with-group-policy-part-3-of-3.aspx

    However this requires OR a Vista machine OR a Windows Server 2008 machine in order to manage it. I would recommend taking a look at those.

    -Bart

  3. Mike said

    if you are running a windows 2003 server with AD you can use a GPO on your computer group(s) to run this script. It will not run every time a user logs in but instead when the computer starts up. Then it will be the computer running, with admin rights, and not the user.

  4. Don said

    Hi Mike,

    That is a good point but the powercfg utility will not work if it is applied to a Computer Configuration. You will need to apply this script to “User Configuration” as the Power Schemes are configured on a per-user basis.

    FYI

    http://www.eggheadcafe.com/software/aspnet/31502004/batch-file-using-powercfg.aspx

    Cheers

    – Don

  5. Mike said

    lol, That just silly then! Silly Microsoft! Thanks Don.
    ~Mike

  6. Jim said

    You may find Data Synergy’s PowerMAN Power Manager useful. This allows you to configure power schemes for XP using GPO. You can create different schemes for different users and also a scheme for when nobody is logged on.

    Most interestingly PowerMAN lets you monitor PC power consumption and track it using a web interface. This can be really useful for spotting problems and working out how effective your scheme is.

    Jim

  7. […] […]

  8. Samuel L. said

    I follow your posts for a long time and must tell you that your articles are always valuable to readers.

  9. Rob Kendrick said

    When applying in a domain environment, use the PSExec utility with the @file parameter. The file should contain a list of the computers you wish to perform this on. I would suggest using a Level 2 account rather than a Domain Admin account, just in a case a machine has been previously compromised. Remember, when you send your credentials to a compromised machine, you’re compromising everything you have access to on your network.

    You can obtain the free PSTools from Microsoft’s website at: http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx

    If you’re a Network or Systems Administrator and you don’t yet use these, I highly recommend you do so. They will save you a lot of time (and potential WMI scripting).

    Enjoy!
    Rob Kendrick
    Finstone IT

  10. GPO said

    Take a look at http://support.microsoft.com/kb/915160, you just use gpo to set registry permisions to allow users to configure their power scheme settings. You prevent users from making changes by removing the Power config control panel applet.

  11. It was by chance I stumbled upon your blog. I have just spent the last 20 mins reading over some of your other posts, your writing style really helps to explain things in a way I can relate to. keep up the good work.

  12. This is an awesome site, I will definitely be adding you to my morning routine 😀

  13. Gerade beim herumstoebern im Netz bin ich auf einmal auf deinem Blog gelandert. Und jetzt komme ich nicht mehr wirklich weg weil mir die Artikel welche du geschrieben hast richtig zu sagen. Sind schoen interessant geschrieben so das man sie gerne liet.

  14. rihatum said

    Hi,

    Great write up and suggestions, is there a way I can power down monitors on log off ?

    I have been looking at nircmd to do this but haven’t had any success yet.

    your help would be appreciated

    thanks

  15. Leona Westbrook-Chilcott said

    Please tell me how to disable to timeout so I can update my i phone. It continually timeouts stopping the download. I have a windows 7. Thanks so much. Leona

  16. […] Powercfg.exe utility « Bart’s Weblog – 26/01/2008 · Today I discovered a very nice utility: powercfg.exe Reason was that I received the question for force a specific power scheme on clients, namely monitor …… […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: