Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

WMI Win32_Battery Information


  • Please log in to reply
3 replies to this topic
Frozenthia
  • Members
  • 59 posts
  • Last active: Sep 10 2013 07:12 PM
  • Joined: 18 Dec 2010
This is not returning all of the object information.

Why? I removed a few of these because I don't need them.
From the rest, I'm only retrieving Availability, Battery Status, Creation Class Name, Design Voltage, Device ID,
Estimated Charge Remaining, Estimated Run Time, Status, System Creation Class Name, and System Name, and am not sure why.

http://msdn.microsof...5(v=VS.85).aspx
http://msdn.microsof...4(v=vs.85).aspx

Perhaps someone else would like to try.
On a separate note, this is useful for those who'd like to code battery life information into a GUI (Or with GDI+ or combination of both).

Credit for this idea goes to user shajul.
strComputer := "."
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . strComputer . "\root\cimv2")

colItems := objWMIService.ExecQuery("Select * from Win32_Battery")._NewEnum
While colItems[objItem]
    MsgBox %  "Availability: " . objItem.Availability
. "`nBattery Recharge Time: " . objItem.BatteryRechargeTime
. "`nBattery Status: " . objItem.BatteryStatus
. "`ncaption: " . objItem.Caption
. "`nChemistry: " . objItem.Chemistry
. "`nConfig Manager Error Code: " . objItem.ConfigManagerErrorCode
. "`nCreation Class Name: " . objItem.CreationClassName
. "`nDescription: " . objItem.Description
. "`nDesign Capacity: " . objItem.DesignCapacity
. "`nDesign Voltage: " . objItem.DesignVoltage
. "`nDevice ID: " . objItem.DeviceID
. "`nEstimated Charge Remaining: " . objItem.EstimatedChargeRemaining
. "`nEstimated Run Time: " . objItem.EstimatedRunTime
. "`nExpected Battery Life: " . objItem.ExpectedBatteryLife
. "`nExpected Life: " . objItem.ExpectedLife
. "`nFull Charge Capacity: " . objItem.FullChargeCapacity
. "`nMax Recharge Time: " . objItem.MaxRechargeTime
. "`nName: " . objItem.Name
. "`nPNP Device ID: " . objItem.PNPDeviceID
. "`nSmart Battery Version: " . objItem.SmartBatteryVersion
. "`nStatus: " . objItem.Status
. "`nStatus Info: " . objItem.StatusInfo
. "`nSystem Creation Class Name: " . objItem.SystemCreationClassName
. "`nSystem Name: " . objItem.SystemName
. "`nTime On Battery: " . objItem.TimeOnBattery
. "`nTime To Full Charge: " . objItem.TimeToFullCharge


Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
replace this
strComputer := "."

objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . strComputer . "\root\cimv2")
with this
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" A_ComputerName "\root\cimv2")
and try it now.

Frozenthia
  • Members
  • 59 posts
  • Last active: Sep 10 2013 07:12 PM
  • Joined: 18 Dec 2010

replace this

strComputer := "."
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\" . strComputer . "\root\cimv2")
with this
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\" A_ComputerName "\root\cimv2")
and try it now.


This works (And I shall use that from now on), but it has not corrected the issue.

Learning one
  • Members
  • 1483 posts
  • Last active: Jan 02 2016 02:30 PM
  • Joined: 04 Apr 2009
Take a look at descriptions for some class Win32_Battery properties:

... This property is not supported ...
...This property is no longer used and is considered obsolete...
...If the battery does not support this function...

So, some properties may not be supported, may not be longer used, not available, and that's why you can't get them all. I also can't get all Win32_Battery Properties when I run code above on my notebook. You could try to get info from CIM_Battery class.