Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Checking Laptop battery info

by !1 (Hermit)
on Jul 10, 2006 at 02:46 UTC ( [id://560059]=note: print w/replies, xml ) Need Help??


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

For win you could do something like this:

#!/usr/bin/perl -l use Win32::OLE('in'); my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\.\\root\\cimv2 +") or die "WMI connection failed.\n"; $colItems = $objWMIService->ExecQuery("Select * from Win32_Battery","W +QL",0x30); print "$_->{DeviceID} ($_->{Description}): $_->{EstimatedChargeRemaini +ng}%" for in $colItems;

Of course, I get percentages greater than 100% when I'm plugged in so it isn't completely ideal. =/

Replies are listed 'Best First'.
Re^3: Checking Laptop battery info
by stonecolddevin (Parson) on Jul 10, 2006 at 20:59 UTC

    well it's most certainly a start. if nothing else i can be like, "hey dad, check this out" :-)

    might even be able to play around with it and see what the problem is with the percentages...

    meh.
      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"; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-24 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found