Solved

Need to access battery status information of other laptops

Posted on 2007-11-19
3
833 Views
Last Modified: 2013-11-17
At my job I have a cart that houses and charges 40 Dell laptops running Windows XP that are periodically loaned out during the course of the day. While the laptops are not in use they are in the cart, powered up and charging.

What I would like to accomplish is to build a console that would reside on a dedicated desktop for the employee of this laptop lending facility. This console would show the percentage of charge that each laptop has (and sort in descending order) so that when a user comes by to borrow a laptop they can be given one with the highest relative charge. I can install an agent on each laptop that would read and "transmit" this data, if necessary. I'm thinking that it probably wouldn't require anything beyond some intermediate VBScripting.

The reason why I'm looking for this is that on busy days (which most are) the turnover rate is too high to ensure that any given laptop has been returned for long enough to recharge all the way. Furthermore, some users will borrow a laptop for 3 hours, sometimes they'll have it back in 20 minutes; this inconsistency combined with the high turnover rate prevents a simple "lend them out in sequential order" approach from ensuring maximum battery life for the user.

Has anybody heard of an existing utility like this?
0
Comment
Question by:ggunnigle
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
MorDrakka earned 500 total points
ID: 20312777
Hi,

This could be scripted with Vbscript + WMI indeed. Unfortunatily I have no laptops here so I cannot test it for you. The attached code uses WMI to read out some battery stats (I removed the unimportant).

When you found the stat you wish to read out each time, basicly you create a loop to read out each laptop and then order the data somewhat.

Replace COMPUTERNAME with the name of the laptop you wish to read out.

Hope this is a start.

M
On Error Resume Next
 

Const wbemFlagReturnImmediately = &h10

Const wbemFlagForwardOnly = &h20
 

arrComputers = Array("COMPUTERNAME")

For Each strComputer In arrComputers

   WScript.Echo

   WScript.Echo "=========================================="

   WScript.Echo "Computer: " & strComputer

   WScript.Echo "=========================================="
 

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")

   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Battery", "WQL", _

                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
 

   For Each objItem In colItems

          WScript.Echo "BatteryStatus: " & objItem.BatteryStatus

      WScript.Echo "Caption: " & objItem.Caption

      WScript.Echo "Description: " & objItem.Description

      WScript.Echo "DesignCapacity: " & objItem.DesignCapacity

      WScript.Echo "DesignVoltage: " & objItem.DesignVoltage

      WScript.Echo "DeviceID: " & objItem.DeviceID

      WScript.Echo "EstimatedChargeRemaining: " & objItem.EstimatedChargeRemaining

      WScript.Echo "EstimatedRunTime: " & objItem.EstimatedRunTime

      WScript.Echo "MaxRechargeTime: " & objItem.MaxRechargeTime

      WScript.Echo "Name: " & objItem.Name

      WScript.Echo "Status: " & objItem.Status

      WScript.Echo "TimeOnBattery: " & objItem.TimeOnBattery

      WScript.Echo "TimeToFullCharge: " & objItem.TimeToFullCharge

      WScript.Echo

   Next

Next
 
 

Function WMIDateStringToDate(dtmDate)

WScript.Echo dtm: 

	WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _

	Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _

	& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))

End Function

Open in new window

0
 

Author Comment

by:ggunnigle
ID: 20313676
MorDrakka,

Thanks, this looks like a great start. I'm having trouble getting it to actually connect to any of the laptops, but that might be becuase of our environment. I neglected to mention that we are on a Novell network without a domain, and each computer is simply set to the domain/workgroup name of "WORKGROUP".

I also need to modify this to display all the info for all the laptops simultaneously in tabular format and have it maybe refresh every 15 seconds, but you seemed to have identified the meat 'n' potatos of accessing the WMI componenet that I need. I'll put some more into this and come back to award points if it works.
0
 

Author Closing Comment

by:ggunnigle
ID: 31409941
I had to do some tweaking on the console machine and the laptops to get them to communicate, but the answer provided me with the foundation I needed. I now have a problem of getting the communication to work over the wireless adapters (works fine when the machines are connected to the same hub), but I suppose that's a whole different thread.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
I am not new to IT, I have been working in the field since 1985.  But recently I came up against something that stumped even me (it doesn't happen as often as I would like).  I was running a screencasting session from the laptop to my TV via ChromeC…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now