VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



WMI sample: retrieve battery info of a (remote) computer

by Anonymous (267 Submissions)
Category: Internet/HTML
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sun 4th May 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

WMI sample: retrieve battery info of a (remote) computer

Rate WMI sample: retrieve battery info of a (remote) computer



' This function lists battery info of a (remote) computer

' Goto http://www.activxperts.com/activmonitor and click on WMI Samples
' for more samples


Sub ListBatteryInfo( strComputer )
    Dim objWMIService, colItems

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Battery",,48)
For Each objItem in colItems
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "BatteryRechargeTime: " & objItem.BatteryRechargeTime
    Wscript.Echo "BatteryStatus: " & objItem.BatteryStatus
    Wscript.Echo "Caption: " & objItem.Caption
    Wscript.Echo "Chemistry: " & objItem.Chemistry
    Wscript.Echo "ConfigManagerErrorCode: " & objItem.ConfigManagerErrorCode
    Wscript.Echo "ConfigManagerUserConfig: " & objItem.ConfigManagerUserConfig
    Wscript.Echo "CreationClassName: " & objItem.CreationClassName
    Wscript.Echo "Description: " & objItem.Description
    Wscript.Echo "DesignCapacity: " & objItem.DesignCapacity
    Wscript.Echo "DesignVoltage: " & objItem.DesignVoltage
    Wscript.Echo "DeviceID: " & objItem.DeviceID
    Wscript.Echo "ErrorCleared: " & objItem.ErrorCleared
    Wscript.Echo "ErrorDescription: " & objItem.ErrorDescription
    Wscript.Echo "EstimatedChargeRemaining: " & objItem.EstimatedChargeRemaining
    Wscript.Echo "EstimatedRunTime: " & objItem.EstimatedRunTime
    Wscript.Echo "ExpectedBatteryLife: " & objItem.ExpectedBatteryLife
    Wscript.Echo "ExpectedLife: " & objItem.ExpectedLife
    Wscript.Echo "FullChargeCapacity: " & objItem.FullChargeCapacity
    Wscript.Echo "InstallDate: " & objItem.InstallDate
    Wscript.Echo "LastErrorCode: " & objItem.LastErrorCode
    Wscript.Echo "MaxRechargeTime: " & objItem.MaxRechargeTime
    Wscript.Echo "Name: " & objItem.Name
    Wscript.Echo "PNPDeviceID: " & objItem.PNPDeviceID
    Wscript.Echo "PowerManagementCapabilities: " & objItem.PowerManagementCapabilities
    Wscript.Echo "PowerManagementSupported: " & objItem.PowerManagementSupported
    Wscript.Echo "SmartBatteryVersion: " & objItem.SmartBatteryVersion
    Wscript.Echo "Status: " & objItem.Status
    Wscript.Echo "StatusInfo: " & objItem.StatusInfo
    Wscript.Echo "SystemCreationClassName: " & objItem.SystemCreationClassName
    Wscript.Echo "SystemName: " & objItem.SystemName
    Wscript.Echo "TimeOnBattery: " & objItem.TimeOnBattery
    Wscript.Echo "TimeToFullCharge: " & objItem.TimeToFullCharge
Next
End Sub



' Main

Dim strComputer
Do
   strComputer = inputbox( "Please enter a computername or . for local computer", "Input" )
Loop until strComputer <> ""

ListBatteryInfo( strComputer )

WScript.Echo( "For more samples, goto http://www.activxperts.com/activmonitor and click" )
WScript.Echo( "on WMI samples" )

Download this snippet    Add to My Saved Code

WMI sample: retrieve battery info of a (remote) computer Comments

No comments have been posted about WMI sample: retrieve battery info of a (remote) computer. Why not be the first to post a comment about WMI sample: retrieve battery info of a (remote) computer.

Post your comment

Subject:
Message:
0/1000 characters