Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: Checking Laptop battery info

by Anonymous Monk
on Dec 07, 2007 at 16:08 UTC ( #655680=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Checking Laptop battery info
in thread Checking Laptop battery info

For Windows scripting checkout Scriptomatic 2.0 from the microsoft scripting guys...

use strict; use Win32::OLE('in'); use constant wbemFlagReturnImmediately => 0x10; use constant wbemFlagForwardOnly => 0x20; my $computer = "localhost"; my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$computer\\roo +t\\CIMV2") or die "WMI connection failed.\n"; my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_Battery" +, "WQL", wbemFlagReturnImmediately | wbemFlagForwardOnly); foreach my $objItem (in $colItems) { print "Availability: $objItem->{Availability}\n"; print "BatteryRechargeTime: $objItem->{BatteryRechargeTime}\n"; print "BatteryStatus: $objItem->{BatteryStatus}\n"; print "Caption: $objItem->{Caption}\n"; print "Chemistry: $objItem->{Chemistry}\n"; print "ConfigManagerErrorCode: $objItem->{ConfigManagerErrorCode}\n +"; print "ConfigManagerUserConfig: $objItem->{ConfigManagerUserConfig} +\n"; print "CreationClassName: $objItem->{CreationClassName}\n"; print "Description: $objItem->{Description}\n"; print "DesignCapacity: $objItem->{DesignCapacity}\n"; print "DesignVoltage: $objItem->{DesignVoltage}\n"; print "DeviceID: $objItem->{DeviceID}\n"; print "ErrorCleared: $objItem->{ErrorCleared}\n"; print "ErrorDescription: $objItem->{ErrorDescription}\n"; print "EstimatedChargeRemaining: $objItem->{EstimatedChargeRemainin +g}\n"; print "EstimatedRunTime: $objItem->{EstimatedRunTime}\n"; print "ExpectedBatteryLife: $objItem->{ExpectedBatteryLife}\n"; print "ExpectedLife: $objItem->{ExpectedLife}\n"; print "FullChargeCapacity: $objItem->{FullChargeCapacity}\n"; print "InstallDate: $objItem->{InstallDate}\n"; print "LastErrorCode: $objItem->{LastErrorCode}\n"; print "MaxRechargeTime: $objItem->{MaxRechargeTime}\n"; print "Name: $objItem->{Name}\n"; print "PNPDeviceID: $objItem->{PNPDeviceID}\n"; print "PowerManagementCapabilities: " . join(",", (in $objItem->{Po +werManagementCapabilities})) . "\n"; print "PowerManagementSupported: $objItem->{PowerManagementSupporte +d}\n"; print "SmartBatteryVersion: $objItem->{SmartBatteryVersion}\n"; print "Status: $objItem->{Status}\n"; print "StatusInfo: $objItem->{StatusInfo}\n"; print "SystemCreationClassName: $objItem->{SystemCreationClassName} +\n"; print "SystemName: $objItem->{SystemName}\n"; print "TimeOnBattery: $objItem->{TimeOnBattery}\n"; print "TimeToFullCharge: $objItem->{TimeToFullCharge}\n"; print "\n"; } sub WMIDateStringToDate(strDate){ return "blah"; }


Comment on Re^4: Checking Laptop battery info
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://655680]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (17)
As of 2015-07-31 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (277 votes), past polls