在Windows XP中使用批处理文件修改电源方案

时间:2022-05-06 00:24:59

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.

我正在尝试编写两个批处理文件,这些文件允许我将电源方案(控制面板 - >电源选项 - >电源方案选项卡)从家庭/办公桌切换到便携式/笔记本电脑并返回。我的操作系统是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.

我这样做的原因是因为我想在我的笔记本电脑上玩游戏时禁用SpeedStep(即将其置于Home / Office Desk方案)并启用SpeedStep(返回便携式/笔记本电脑)。 Windows XP会在Home / Office Desk模式下关闭动态切换。我希望能够以编程方式执行此操作,以便每次我想玩游戏时节省一些时间。

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.

有关如何使用简单批处理文件修改电源设置的任何想法? Python和Ruby脚本也是一种选择,但不是首选。

2 个解决方案

#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.

也许你需要调整“tokens = 2,3 delims = :()”FOR选项;此代码是为Windows 8.1西班牙语版本编写的。

#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.

也许你需要调整“tokens = 2,3 delims = :()”FOR选项;此代码是为Windows 8.1西班牙语版本编写的。