Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a batch file to change the power options in Windows 7

Tags:

batch-file

Is there a way to create batch file and place it on the desktop to change the power options in Windows 7? Specifically I have the computer set to sleep after 30 minutes. Now that I use "Serve To Me/Stream To Me" apps I want to quickly be able to change the power settings to allow continuous operation and then quickly change the power settings back to 30 minute sleep when i'm done using the streaming apps. How is this done? Can it be done?

Thanks Gary

like image 866
zoom38 Avatar asked Nov 28 '25 06:11

zoom38


2 Answers

Create or modify the power schemes you want to use.

Launch RegEdit and navigate to:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\User\PowerSchemes

Look through the schemes and find the GUID (long strings of characters) of the scheme you want to use.

Create a batch file like so:

@echo off
powercfg -s (GUID of the Scheme you wish to switch to.)
pause (Optional)

Name the batch file(s) appropriately.

You will make one batch file for each scheme you want to switch to.

like image 79
Lance Avatar answered Nov 30 '25 00:11

Lance


@echo off
setlocal EnableDelayedExpansion

echo Available power schemes:
echo/

set i=0
set "options="
for /F "tokens=2,3 delims=:()" %%a in ('powercfg /L') do if "%%b" neq "" (
   set /A i+=1
   set "options=!options!!i!"
   echo !i!. %%b
   set "scheme[!i!]=%%a"
)

echo/
choice /C %options% /N /M "Select desired scheme: "
powercfg /S !scheme[%errorlevel%]!
echo/
echo Power scheme set

Perhaps you need to change the "tokens=2,3 delims=:()" FOR options to match your version or locale. I developed this code in my Windows 8.1 Spanish version; this is an output example:

Available power schemes:

1. Certificado ENERGY STAR
2. Alto rendimiento
3. Economizador

Select desired scheme: 1

Power scheme set
like image 43
Aacini Avatar answered Nov 30 '25 00:11

Aacini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!