【问题标题】:Modifying the Power Scheme using Batch Files in Windows XP在 Windows XP 中使用批处理文件修改电源方案
【发布时间】:2009-04-29 03:01:38
【问题描述】:

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

我这样做的原因是因为我想在我的笔记本电脑上玩游戏时禁用 SpeedStep(即把它放在家庭/办公桌方案上),否则启用 SpeedStep(回到便携式/笔记本电脑)。 Windows XP 在家庭/办公桌模式下启用turns off 动态切换。我希望能够以编程方式执行此操作,以便在每次我想玩游戏时节省一些时间。

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

【问题讨论】:

    标签: windows batch-file controlpanel


    【解决方案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
      

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

      【讨论】:

        猜你喜欢
        • 2010-12-02
        • 2023-02-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-06
        • 1970-01-01
        相关资源
        最近更新 更多