批处理脚本以关闭监视器?



我已经在Win-7上测试了这两个命令:

powercfg.exe -x -monitor-timeout-ac 0
powercfg.exe -change -monitor-timeout-ac 0

他们已成功关闭我的显示器。我知道它们是相同的,但是哪一个更好并且与所有Windows版本兼容?此脚本可以在 Win 10 上运行良好并且无需管理员权限吗?

来自 Help (powercfg/?)

它们是相同的-X是为懒得打-change的人准备的。

-CHANGE, -X Modifies a setting value in the current power scheme.
Usage: POWERCFG -X <SETTING> <VALUE>
<SETTING>   Specifies one of the following options:
-monitor-timeout-ac <minutes>
-monitor-timeout-dc <minutes>
-disk-timeout-ac <minutes>
-disk-timeout-dc <minutes>
-standby-timeout-ac <minutes>
-standby-timeout-dc <minutes>
-hibernate-timeout-ac <minutes>
-hibernate-timeout-dc <minutes>
Example:
POWERCFG -Change -monitor-timeout-ac 5
This would set the monitor idle timeout value to 5 minutes
when on AC power.

Windows 10的cmd行中,我运行powercfg /?

/CHANGE,/X 修改当前电源方案中的设置值。

/X/CHANGE都是有效的开关,当我在Windows 10上运行它时,这意味着它可以工作。

此外,尽管使用-作为有效的开关激活器,您也可以使用 Windows 默认值/

powercfg.exe /change /monitor-timeout-ac 0
powershell (Add-Type '[DllImport("user32.dll")]^public static extern int PostMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2)

将其另存为 BAT 文件。(EF offmonitors.bat) 关闭所有屏幕。(使用管理员权限运行)

最新更新