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 10 Pro 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 10 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 10 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
Thread Forum
BSOD While Computer Sleeps
Hello. I hope I am posting this right. My system specs are updated. I noticed this problem about a week ago. Every now and then when I wake my laptop up from sleep it is shut down. I press the power on button and I get the "windows did not shut down properly" and when I click on details of the...
BSOD Help and Support
BSOD Every morning after computer sleeps
Hello, I put my HP 8540p to sleep every night and always come back to a BSOD "DRIVER_POWER_STATE_FAILURE". I have run all Windows Updates, HP Updates, and antivirus scans. My troubleshooting skills do not go any further than this. I have followed the instructions for BSOD postings, and the...
BSOD Help and Support
BSOD whenever computer sleeps
Hi, whenever my computer goes to sleep, I either get a BSOD when I turn it back on, or go straight to the black screen with boot options for "windows has recovered from an unexpected shutdown". the two BCCodes I've been getting are 7a and f4, I think the difference being when I send the...
BSOD Help and Support
BSOD when computer sleeps
Hello, My computer has been randomly crashing after it goes to sleep. After trying to find answers by searching, it seems like it may have to do with a driver, but I can't understand the dmp files. I also cannot open the xml file. Attached is the message I get when I start the computer again. ...
BSOD Help and Support
BSOD while Computer Sleeps
Hi, I keep getting a BSOD while my computer is sleeping. I have tried looking through the reports myself but keep seeing different causes which makes me think maybe its happening when the computer wakes up. Any help would be appreciated. This started happening after Battle Field 3. I...
BSOD Help and Support
Monitor sleeps, computer doesn't -> Help :O
Well I've come across a problem. For some reason, when I go to Start > Sleep, my monitor enters a stand-by sleep mode, but my computer won't. Since the monitor has its power off and I can't see anything, and the computer is still on, I have to manually shut down by holding the power button down. It...
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 01:52.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App