I have the following scenario:

I am testing several laptops with Windows 8.1 installed. One of the tests is to measure how much the battery lasts. For this task I use benchmarks like PeaceKeeper or PowerMark.

I also want to measure how long it takes for the battery to charge itself to 100% after it gets depleted. Any ideas on how to do that?


If you do not want to use external tools, you could tap the power (pun intended) of WMI queries and WMI Eventing. Simple query to run from command line:

wmic path win32_battery get EstimatedChargeRemaining

will give you estimated charge. Now, to get repeated readings you could just put it in a timed loop, but there is a better (or fancier :-) way: register a battery event and a handler for it - here it is done in Powershell (start Powershell and paste/exec those two commands):

$action={get-wmiobject -computername localhost -Query "Select * from Win32_Battery"|% {write-host battery charge: ($_.EstimatedChargeRemaining) time:  $(get-date)}}

Register-WMIEvent -query "SELECT * FROM __InstanceModificationEvent WITHIN 10 WHERE TargetInstance ISA 'Win32_Battery'" -messageData "battery charge" -sourceIdentifier "battery" -action $action

This will produce a line of output at your Powershell console each time an event is raised. Here is the output from my laptop:

battery charge: 67 time: 2014-12-11 17:59:53
battery charge: 68 time: 2014-12-11 18:00:23
battery charge: 69 time: 2014-12-11 18:01:23
battery charge: 70 time: 2014-12-11 18:01:53
battery charge: 71 time: 2014-12-11 18:02:53
battery charge: 72 time: 2014-12-11 18:03:23
battery charge: 73 time: 2014-12-11 18:04:23
battery charge: 74 time: 2014-12-11 18:05:14
battery charge: 75 time: 2014-12-11 18:06:04
battery charge: 76 time: 2014-12-11 18:06:44

My simple action is just a console message, but you could of course do whatever you like - for example write it out to file

(note: I think WMI counter goes to 99 which is shown as 100%/full at the status bar - so it's 1% 'behind' the display)

  • That's a neat trick. WMI comes in handy for a lot of stuff. If only it were easy to learn. Are you aware of any good places to start learning about it? +1 to you. – Vinayak Dec 11 '14 at 19:47
  • 1
    @Vinayak MSDN has quite a lot of information, see here for examples: msdn.microsoft.com/en-us/library/aa394585%28v=vs.85%29.aspx Related so question: stackoverflow.com/questions/896188/… – wmz Dec 11 '14 at 21:52
  • When I run wmic path win32_battery get EstimatedChargeRemaining, I get 4 as the result. What does that mean? How do you interpret the results? – Corporate Geek Dec 15 '14 at 13:19
  • @CorporateGeek This should be percentage: EstimatedChargeRemaining Data type: uint16 Access type: Read-only Estimate of the percentage of full charge remaining (full class reference msdn.microsoft.com/en-us/library/aa394074%28v=vs.85%29.aspx) – wmz Dec 15 '14 at 13:26
  • Mmm... wmic path win32_battery get EstimatedChargeRemaining is not useful then. It tells me how much charge the battery has. I need to measure exactly how long it takes for a battery to charge from empty to 100%. – Corporate Geek Dec 15 '14 at 13:29

Battery Eater supports creating a battery charging graph.

Battery Eater

It also logs the current battery capacity every 30 seconds during a discharge benchmark. I suppose it also logs this information while creating the charging graph.

Here's a snippet of the discharge log:

Log started: 13-01-2014 20:15:43
[20:16:13]  36680   0
[20:16:43]  36630   0
[20:17:13]  36590   0
[20:17:43]  36530   0
[20:18:13]  36490   0
[20:18:43]  36430   0
[20:19:13]  36370   0
[20:19:43]  36320   0
[20:20:13]  36280   0
[20:20:43]  36220   0
[20:21:13]  36170   0
[20:21:43]  36110   0
[17:52:38]  2080    0
[17:53:08]  2250    0
[17:53:38]  2410    0
Log ended: 14-01-2014 17:53:45

To open the BEG files it generates, drag-and-drop them into the Battery Eater executable file. Also, since this is pretty old software, you may need to run it in Compatibility mode.

  • Where is that BEG file generated? Where do you find it? – Corporate Geek Dec 15 '14 at 13:21
  • The BEG files are generated in the same folder as BEPro.exe. The folder names correspond to the current date, so if you did a benchmark today, they's be named 15_12_2014_1, 15_12_2014_2, 15_12_2014_3 etc. The BEG files are located inside these folders along with the log file. – Vinayak Dec 15 '14 at 15:36

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.