"Prof Wonmug" <wonmug@moo.gov> wrote in message
news:5og086d7657qqpmlolfocrgjs0mv6jkfu3@4ax.com...
> Where could I get an applet that would wake up every 30 minutes, read
> the battery strength on my laptop, and write the results to a file?
>
> I looked at several shareware apps that monitor the battery, but
> didn't see any that can make a log.
>
> Any suggestions or pointers?
You could do it like this:
1. Save the code below as c
Windows\BatteryMonitor.vbs
2. Create a scheduled task that runs once every 30 minutes. It should
execute the following command:
cscript //nologo c
Windows\BatteryMonitor.vbs >>
c
Windows\BatteryMonitor.log
3. Examine the log file c
Windows\BatteryMonitor.log
Note that the battery interface appears to differ somewhat between
manufacturers. The code works on my Acer laptop but it may fail on your own
machine.
Set oWMIService = GetObject("winmgmts
\.\root\CIMV2")
Set cItems = oWMIService.ExecQuery( _
"SELECT * FROM Win32_Battery",,4
For Each oItem In cItems
sOutput = Date() & " " & Time() & ": " _
& "Remaining charge=" & oItem.EstimatedChargeRemaining & "%"
If oItem.BatteryStatus = 1 _
Then sOutput = sOutput & ", Remaining time=" & oItem.EstimatedRunTime & "
minutes"
WScript.Echo sOutput
Next