Solved

Need to access battery status information of other laptops

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Lithium-ion batteries area cornerstone of today's portable electronic devices, and even though they are relied upon heavily, their chemistry and origin are not of common knowledge. This article is about a device on which every smartphone, laptop, an…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 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