[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 847
  • Last Modified:

Need to access battery status information of other laptops

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
ggunnigle
Asked:
ggunnigle
  • 2
1 Solution
 
MorDrakkaCommented:
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
 
ggunnigleAuthor Commented:
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
 
ggunnigleAuthor Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now