Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Change when the computer sleeps - from cmd line


04 Jan 2012   #1
rhinse

Windows Home Premium 32bit
 
 
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 System SpecsSystem Spec
04 Jan 2012   #2
Sedril

Windows 7 Ultimate SP1 x64
 
 

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 System SpecsSystem Spec
04 Jan 2012   #3
Ztruker

Windows 8 Core X64
 
 

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 System SpecsSystem Spec
05 Jan 2012   #4
rhinse

Windows Home Premium 32bit
 
 

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 System SpecsSystem Spec
05 Jan 2012   #5
rhinse

Windows Home Premium 32bit
 
 

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 System SpecsSystem Spec
06 Jan 2012   #6
logicearth

Windows 8.1 Pro (x64)
 
 

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 System SpecsSystem Spec
06 Jan 2012   #7
rhinse

Windows Home Premium 32bit
 
 

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 System SpecsSystem Spec
06 Jan 2012   #8
logicearth

Windows 8.1 Pro (x64)
 
 

I got the information from "powercfg /?"
Anything that can be changed in the UI for power, can be done in the command line.
My System SpecsSystem Spec
06 Jan 2012   #9
rhinse

Windows Home Premium 32bit
 
 

Quote:
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 System SpecsSystem Spec
Reply

 Change when the computer sleeps - from cmd line




Thread Tools



Similar help and support threads for2: Change when the computer sleeps - from cmd line
Thread Forum
Solved Another BSOD when computer sleeps issue BSOD Help and Support
Solved BSOD Every morning after computer sleeps BSOD Help and Support
BSOD whenever computer sleeps BSOD Help and Support
BSOD when computer sleeps BSOD Help and Support
Solved BSOD while Computer Sleeps BSOD Help and Support
This device can't access your media when your computer sleeps? Network & Sharing
Monitor sleeps, computer doesn't -> Help :O General Discussion

Our Sites

Site Links

About Us

Find 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 09:09 AM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App