从命令行更改关闭盖子的功能?


8

我想知道是否有人知道实用程序或命令,它们可以一键更改Windows中的此设置。我是否经常需要在笔记本电脑上进行更改,无论我是希望在合上盖子或进入睡眠状态时不执行任何操作。

我确信可以从命令行进行某种更改。

Answers:


19

取自套盖关闭电源选项。此页面上还有一个或两个脚本,但是下面复制的方法是最好的,恕我直言。


您可以通过powercfg命令进行设置。

预先配置的方案具有以下GUID:

Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e  (Balanced)
Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c  (High performance)
Power Scheme GUID: a1841308-3541-4fab-bc81-f71556f20b4a  (Power saver)

我将使用Balanced方案作为示例,但您将使用以下提供的GUID:

powercfg -GETACTIVESCHEME

通过使用方案GUID运行查询命令,可以找到子组和电源设置的GUID以及每个电源设置的索引值:

powercfg -Q 381b4222-f694-41f0-9685-ff5bb260df2e

查看输出,您将发现所需的子组GUID是:

Subgroup GUID: 4f971e89-eebd-4455-a8de-9e59040e7347  (Power buttons and lid)

和电源设置:

Power Setting GUID: 5ca83367-6e45-459f-a27b-476b1d01c936  (Lid close action)

带有索引选项:

Possible Setting Index: 000
Possible Setting Friendly Name: Do nothing
Possible Setting Index: 001
Possible Setting Friendly Name: Sleep
Possible Setting Index: 002
Possible Setting Friendly Name: Hibernate
Possible Setting Index: 003
Possible Setting Friendly Name: Shut down

因此,为了将您的系统配置为在关闭机盖后关闭,请运行:

powercfg -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 3
powercfg -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 3

AC表示“插入”操作,DC表示“使用电池”操作。


希望这可以帮助。

请注意,我没有加引号,因为它弄乱了相当长的代码行。因此,为格式化起见,我将其省略。


1

powercfg 支持向导的别名(方案名称,组等)

@echo off

powercfg /s scheme_min
rem scheme_min is high performance

powercfg /setacvalueindex scheme_min sub_buttons lidaction 0
rem under buttons group; plugged in

powercfg /setdcvalueindex scheme_min sub_buttons lidaction 0

rem dc means on battery

rem check with powercfg.cpl gui

rem use powercfg /aliases for aliases instead of guid numbers

rem query with powercfg /q

上面的脚本将切换到高性能方案,并在两种情况下(插上电源或用电池供电)将其下盖操作(When I close the lid:)设置为None

它基本上是三行代码,其余的几乎只是注释(rem arks)。


1

以下似乎是从命令行更改当前活动电源方案的行为的最简单,也有些可读的方法(由于w17t的回答TenForums的帖子):

关闭Lid.bat时不执行任何操作
::Do nothing when you close the lid
powercfg /setacvalueindex scheme_current sub_buttons lidaction 0
powercfg /setdcvalueindex scheme_current sub_buttons lidaction 0

::Re-activate current scheme to make settings take effect immediately
powercfg /setactive scheme_current
GoSleepWhenClosingTheLid.bat
::Go to sleep/standby mode when you close the lid
powercfg /setacvalueindex scheme_current sub_buttons lidaction 1
powercfg /setdcvalueindex scheme_current sub_buttons lidaction 1

::Re-activate current scheme to make settings take effect immediately
powercfg /setactive scheme_current
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.