Solved

Need to access battery status information of other laptops

Posted on 2007-11-19
3
838 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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