做网站咋做,直播网站开发,怎么做网页图片空间,php网站开发师条件有时夜晚将亮度调到最暗#xff0c;早上想调回来时太暗又看不到#xff0c;想写一个脚本调。参考 [1,2]#xff0c;可用 powershell 命令实现。顺便记录 powershell 脚本参数写法。
Code
# brightness.ps1# 命令行参数 b#xff0c;[0, 100]#xff0c;默认 50
param ($…有时夜晚将亮度调到最暗早上想调回来时太暗又看不到想写一个脚本调。参考 [1,2]可用 powershell 命令实现。顺便记录 powershell 脚本参数写法。
Code
# brightness.ps1# 命令行参数 b[0, 100]默认 50
param ($b 50)
# echo $b
# 改亮度
(Get-WmiObject -Namespace root/WMI -Class WmiMonitorBrightnessMethods).WmiSetBrightness(1,$b)powershell 脚本后缀是 .ps1存为 brightness.ps1。接受命令行参数的写法参考 [3]设默认值参考 [4]。运行
.\brightness.ps1
# 或指定亮度 [0, 100]
.\brightness.ps1 -b 90不过 powershell 默认禁止运行脚本参考 [5,6]可以
提前在任一 powershell 运行 Set-ExecutionPolicy -Scope CurrentUser Bypass对当前用户赋权。会记在注册表今后都能运行可用 Get-ExecutionPolicy -Scope CurrentUser 验证或用 unblock-file brightness.ps1[7,8]无效或在当前 powershell对此 shell赋权Set-ExecutionPolicy -Scope Process Bypass有点麻烦或用 pwsh.exe -ExecutionPolicy Bypass 另起一个赋权的子 shell。无 pwsh 命令
Run in cmd
powershell 脚本只能在 powershell 入面直接用 .\script.ps1 或 path\script.ps1 执行且要放 bypass 权才方便。
如果不想放权参考 [9]考虑写个 .bat 文件在 cmd 套娃运行 powershell 脚本用到 powershell 命令。
REM bright.bat
echo off
REM 命令行参数
if (%1) () (set b50
) else (set b%1
)
REM echo %b%
REM 执行 powershell 脚本临时放权
powershell -executionpolicy bypass -File brightness.ps1 %b%执行 bright.bat 或 bright.bat 亮度 即可放在 %USERPROFILE%/ 下cmd 启动路径即可 Ctrl R 呼出 cmd 后盲敲。
References
7 ways to adjust the screen brightness in Windows 10Windows 11 Change Display Brightness with 9 methodsabout_Scriptsabout_Parameters_Default_Valuesabout_Execution_PoliciesSet-ExecutionPolicyabout_SigningUnblock-FileHow to run a PowerShell script