Change when the computer sleeps - from cmd line


  1. Posts : 34
    Windows Home Premium 32bit
       #1

    Change when the computer sleeps - from cmd line


    I ocassionally like to switch the time the computer goes to sleep from 'Never' to
    '5 minutes' or thereabouts every so often. I have been looking for a way to
    automate that process. Wading through control panel to the settings page takes
    a while and I don't use a standard keyboard and mouse on my Media Center box
    to navigate.

    I can shorten it somewhat by creating a command line shortcut containing the following:

    Code:
    control /name Microsoft.PowerOptions
    but this only gets me down about 2 layers and I still have to try to use an unweildy
    mouse and keyboard to get to the next page and change the settings.

    Is there any way to create another batch file or some other script that will
    perform this function w/o having to change the settings from the window screens?
    Perhaps a .reg file to change the setting in the registry, if that's where it is?
      My Computer


  2. Posts : 109
    Windows 7 Ultimate SP1 x64
       #2

    The easiest way would be to create the two profiles you want, one under balanced, and one under high performance, or power save...... and then just use a shortcut to switch between them... no batch file needed that way... would be as simple as clicking a shortcut to go back and forth...



    Edit: here is a link to the tutorial... that might have been helpful....

    Power Plan - Create Shortcut to Change Power Plan
      My Computer


  3. Posts : 6,285
    Windows 10 Pro X64
       #3

    Never mind , wrong sleep

    Maybe this: Standby and Hibernate from Command Line - HTFC Forums

    Allows you to put the computer into StandBy mode (another name for sleep I think).
      My Computer


  4. Posts : 34
    Windows Home Premium 32bit
    Thread Starter
       #4

    I had seen the references to changing power plans but thought that was
    a bit excessive and unnecessary since I can change the settings
    'When the computer sleeps' within the same power plan by changing the
    settings in control panel.

    Presumably, switching to an alternate power plan via the referenced
    shortcuts would necessitate changing the 'Change when the computer sleeps'
    setting under one particular alternate plan while retaining the default
    for the other. This would not seem all that involved but when I made a
    comparison of the Power registry key set to "Never" and "5 minutes", under
    the same power plan, the only change was to the following key:

    Never:
    Code:
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\
    381b4222-f694-41f0-9685-ff5bb260df2e\
    238c9fa8-0aad-41ed-83f4-97be242c8f20\
    29f6c1db-86da-48c5-9fdb-f2b67b1f44da]
    "ACSettingIndex"=dword:00000000
    Five Minutes:
    Code:
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes\
    381b4222-f694-41f0-9685-ff5bb260df2e\
    238c9fa8-0aad-41ed-83f4-97be242c8f20\
    29f6c1db-86da-48c5-9fdb-f2b67b1f44da]
    "ACSettingIndex"=dword:0000012c
    Unfortunately, when I tried to place each different setting into .reg files and load them into the
    registry, I got the following error message:

    Code:
     Cannot import File.reg: Not all data was successfully wrtten to
    the registry. Some keys are open by the system or other processes.
    Apparently security configurations only allow the change to "ACSettingIndex" if it is done through the control panel.

    I also do not wish to enter sleep/hybrid sleep mode with a command line entry, so
    "Standby and Hibernate from Command Line" doesn't apply. I simply want to change
    the idle time before the system enters sleep mode automatically.

    While I haven't yet tested the shortcuts switching power plans, I wonder if there
    isn't some other way to alter the "ACSettingIndex" under the same user. If Microsoft
    allows it through Control Panel, it would seem possible.
      My Computer


  5. Posts : 34
    Windows Home Premium 32bit
    Thread Starter
       #5

    OK, maybe not.

    The shortcut files from the Power Plan Tutorial work well even though some
    additional keys are added to the registry. It is unclear which ones actually
    control the 'Sleep time' now but after changing the sleep time under one of
    the power plans to 5 minutes and leaving the other at 'Never', I can switch
    back and forth with one click.

    The only change to the registry that occurs now is:

    Code:
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes]
    "ActivePowerScheme"="381b4222-f694-41f0-9685-ff5bb260df2e"
    
    [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\PowerUser\PowerSchemes]
    "ActivePowerScheme"="a1841308-3541-4fab-bc81-f71556f20b4a
      My Computer


  6. Posts : 5,642
    Windows 10 Pro (x64)
       #6

    There you go (change ac to dc for battery)
    Code:
    powercfg -change -standby-timeout-ac 20
    More info:
    Code:
      -CHANGE, -X Modifies a setting value in the current power scheme.
    
                  Usage: POWERCFG -X <SETTING> <VALUE>
    
                  <SETTING>   Specifies one of the following options:
                              -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>
    
                  Example:
                      POWERCFG -Change -monitor-timeout-ac 5
    
                  This would set the monitor idle timeout value to 5 minutes
                  when on AC power.
      My Computer


  7. Posts : 34
    Windows Home Premium 32bit
    Thread Starter
       #7

    Thanks, I knew there must be a way to do it!
    Code:
    powercfg -change -standby-timeout-ac
    works perfectly w/o the registry bloat of changing Active Power Plan

    Just out of curiosity, where did you get this info?
      My Computer


  8. Posts : 5,642
    Windows 10 Pro (x64)
       #8

    I got the information from "powercfg /?"
    Anything that can be changed in the UI for power, can be done in the command line.
      My Computer


  9. Posts : 34
    Windows Home Premium 32bit
    Thread Starter
       #9

    Anything that can be changed in the UI for power, can be done in the command line.
    I would have thought the same, but until you came forward with the specifics, I
    was at a loss. I've never tinkered much with power settings or any other Windows
    settings for that matter, so I'm a babe in the woods about a lot of things.

    Thanks for your help. I don't know when I have had a better outcome to a problem.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 13:34.
Find Us