2
1
Is there a way to differentiate between AC and battery power on a laptop to be used in Win 7 Task Scheduler?
2
1
Is there a way to differentiate between AC and battery power on a laptop to be used in Win 7 Task Scheduler?
3
@echo off
set bstat=
for /f "tokens=2 delims==" %%a in ('wmic path Win32_Battery get BatteryStatus /value ^| find "="') do set bstat=%%a
if [%bstat%]==[1] echo The battery is discharging.
if [%bstat%]==[2] echo The system has access to AC so no battery is being discharged. However, the battery is not necessarily charging.
if [%bstat%]==[3] echo Battery fully charged.
if [%bstat%]==[4] echo Battery low.
if [%bstat%]==[5] echo Battery critical.
if [%bstat%]==[6] echo Battery charging.
if [%bstat%]==[7] echo Battery charging and high.
if [%bstat%]==[8] echo Battery charging and low.
if [%bstat%]==[9] echo Battery charging and critical.
if [%bstat%]==[10] echo Battery status undefined.
if [%bstat%]==[11] echo Battery partially charged.
The batch file above uses the Win32_Battery WMI class to get the battery status. Extend it to perform the required action(s), then use task scheduler to run it as and when required.
Excellent, it is quite strange. I thought it would have been a recorded event. Would +1, cannot at present. Will do when I get +15. Thanks – Arthor – 2015-04-26T08:22:51.363
This is the only standalone solution. Awesome. Thanks – Aaron Gillion – 2015-12-28T09:16:55.307