Solved

Need to access battery status information of other laptops

Posted on 2007-11-19
3
836 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you will get to know about pros and cons of storage drives HDD, SSD and SSHD.
I'm a big fan of Windows' offline folder caching and have used it on my laptops for over a decade.  One thing I don't like about it, however, is how difficult Microsoft has made it for the cache to be moved out of the Windows folder.  Here's how to …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

15 Experts available now in Live!

Get 1:1 Help Now