Saturday, 12 June 2021

Battery Alert Using Batch Program

:repeat
Goto get-battery
Echo "%Ba%"
:Next
TIMEOUT /T 600  
if "%Ba%"  GEQ "80" Goto Alert
goto repeat
 
:Alert
echo Your battery has finished charging
mshta javascript:alert("Unplug charger");close();
TIMEOUT /T 500
goto repeat
 
:get-battery
for /f "tokens=2 delims==" %%E in ('wmic path Win32_Battery get EstimatedChargeRemaining /value') do (set "Ba=%%E")
Goto Next


Save the above code in a .bat file. Place this file in startup (shell:startup)

No comments:

Post a Comment