Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Laptop - Power Management - Estimated Time Remaining 1

Status
Not open for further replies.

Ligneous

MIS
Jan 17, 2004
4
0
0
GB
Windows 2000 – I am unable to find an option to get the Battery Power Meter to display the Estimated Time Remaining on my personal Systemax Laptop as is displayed on the Compaq Laptops we issue to our users. I am now wondering whether this feature is maybe Compaq / BIOS specific, or whether I am missing something particularly obvious. I have previously run XP Pro on the Systemax but could not find the option there either.

Any help appreciated.
 
Hello ligneouse,

You can make the following plaintext scriptfile with .vbs extension.
Code:
set svc=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_portablebattery"
for each oprtbat in svc.execquery(sQuery)
    wscript.echo "Estimated charge remaining(%) : " & oprtbat.EstimatedChargeRemaining & vbcrlf & _
        "Estimated Runtime (min) : " & oprtbat.EstimatedRuntime
next
set svc=nothing
wscript.echo "done"
Double-click on it to run. See if it meets your need.

regards - tsuji
 
tsuji,

I thought the WMI class was: Win32_Battery

As in:

Set BatterySet=GetObject("winmgmts:").InstancesOf("Win32_Battery")

For each Battery in BatterySet

Wscript.Echo "Name: " & Battery.Description & VBlf & _
"Type: " & Btype & VBlf & _
"% Left: " & Battery.EstimatedChargeRemaining & VBlf & _
"Minutes Left: " & Battery.ExpectedLife & _
"Status: " & Bstatus

Next


 
Hello bcastner,

Many wmi classes are derived from overlapping parent classes. As ligneous asking for the laptop, I thought it might be worthwhile to start with win32_portablebattery. I am actually quite neutral on the choice between that and win32_battery as a starter. I would encourage ligneous to try out both. In fact the property sets of both are quite rich. Some certain would be useful for some hardware people frequenting the forum to explore. Thanks for the idea.

regards - tsuji
 
tsuji,

Excellent work, as always.
I very much appreciate the MS KB note for XP.

I have just begun exploring WMI reporting, and was curious as to your choice of class.

A star for your excellent advice.

Best,
Bill

 
Thanks guys - I have no knowledge of vbs at all but have managed to make some sense of what you say and have played around a litle with the script.

The most functional script so far was actually using Win32_Battery, but the "Minutes Left: " and "Status: " fields remain blank.

Do you think I am missing something particularly obvious?


regards - Lig
 
Ligneous,

I try here to modify a bit bcastner's renderment see if it improves a bit the message extracted.
Code:
set batteryset=getobject("winmgmts:").instancesof("win32_battery")
for each battery in batteryset
    with battery
    wscript.echo "Name: " & .Name & vbcrlf & _
        "Description: " & .Description & vbcrlf & _
        "% Left: " & .EstimatedChargeRemaining & vbcrlf & _
        "Minutes Left: " & .ExpectedRunTime & vbcrlf & _
        "Status: " & .Status
    end with
next
set batteryset=nothing
Also could you post back what you've got? Thanks.

- tsuji
 
Correction:

The corresponding line above should be read as:
Code:
        "Minutes Left: " & .[red]Estimated[/red]RunTime & vbcrlf & _
- tsuji
 
tsuji,

I am happier with the WMI class Win32_Battery.
And I tend to script without SQL statements.

But I enjoyed your efforts above, and thanks.
Bill
 
bcastner,

It is only a matter of style, in particular for the collection returned is usually small for win32_battery. For a huge return set, sql-like query is quicker---but, that's just a detail.

The reason why I tried at all to modify your script a bit is that I saw [1] Btype and Bstatus actually are not well-defined; [2] that .ExpectedLife is assuming the battery is fully charged, hence, to get what % left, we should use .EstimatedRunTime instead.

- tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top