这是一个简单的批处理文件,用于显示低电量通知。它的组成部分是从其他人民的职位中挑选出来的,并进行了测试。我很困惑,但当我添加'hasBeenNotified‘支票时,我想我弄坏了它。
@ECHO OFF
setlocal
set multipleNotification=5
set BatteryLevel=-1
set notificationThreshold=20
set hasBatteryNotified=0
:: if on battery
wmic Path Win32_Battery Get BatteryStatus | find "2" > nul
if %errorlevel% neq 0 (
:: if battery level low, notify
for /f %%a in ('wmic.exe path Win32_Battery get EstimatedChargeRemaining ^| findstr.exe /r "[0-9][0-9]*"') do set BatteryLevel=%%a
set /a notMultiple = %BatteryLevel% %% %multipleNotification%
if %BatteryLevel% leq %notificationThreshold% if %notMultiple%==0(
:: if not notified
if %hasBatteryNotified%==0(
start cmd /K echo Batery is at %BatteryLevel%!!
set hasBatteryNotified=1
)
) else (
set hasBatteryNotified=0
)
) else (
set hasBatteryNotified=0
)发布于 2015-09-08 18:50:05
if %hasBatteryNotified%==0 (和
if %BatteryLevel% leq %notificationThreshold% if %notMultiple%==0 (在(之前必须有空格(是的,批处理对空格非常挑剔)
https://stackoverflow.com/questions/32464963
复制相似问题