Modifying the Power Scheme using Batch Files in Windows XP

*爱你&永不变心* 提交于 2019-12-13 03:11:44

问题


I'm trying to write two batch files that will allow me to switch the Power Scheme (Control Panel -> Power Options -> Power Schemes Tab) from Home/Office Desk to Portable/Laptop and back. My operating system is Windows XP SP3.

My reason for doing this is because I want to disable SpeedStep when I'm playing games on my laptop (i.e. put it on the Home/Office Desk scheme) and enable SpeedStep otherwise (back to Portable/Laptop). Windows XP turns turns off dynamic switching in Home/Office Desk mode. I'd like to be able to do this programatically to save myself some time everytime I want to play a game.

Any thoughts on how to modify the power settings using a simple batch file? Python and Ruby scripting is also an option but isn't preferred.


回答1:


C:>%windir%\system32\powercfg.exe /?

    /SETACTIVE, /S  Makes the power scheme with the specified name active.
Examples:
    POWERCFG /SETACTIVE scheme



回答2:


@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 adjust the "tokens=2,3 delims=:()" FOR options; this code was written for Windows 8.1 Spanish version.



来源:https://stackoverflow.com/questions/800713/modifying-the-power-scheme-using-batch-files-in-windows-xp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!