From the forums: IBM Lenovo Battery Test

The message can be located at:

http://www.myitforum.com/forums/fb.asp?m=143180

IBM Lenovo Battery Test

I wrote this for our end users to check their system for a defective battery per the Lenovo recall. The script verifies the host system is an IBM/Lenovo and queries WMI for the battery model info. If the system is not an IBM/Lenovo, it returns a message stating it is only intended to be run on those platforms. If the battery info is not found, it returns a message stating that it is only intended to be run on laptop/notebook systems and provides the option to open to the Lenovo recall site. If a battery on the recall list is found, it instructs the users to contact the help desk for instructions and also provides the option to open the recall site. If you wish to direct the users to your intranet site, just change the value of the variable strURL (be sure to include the full URL and enclose the value in quotes).

Here goes the disclaimer....

Use At Your Own Risk!

This code is provided 'as is', without warranty of any type. The author does not guarantee the accuracy of the information produced by this script.

Copy and paste the code into a text editor (word wrap off) and save with a .vbs extension...

' BatteryCheck.vbs

' Checks Laptop Battery against list of recalled models ' Jay Schramke ' 09292006 ' ****WARNING**** ' Use at your own risk!

' The author does not guarantee the accuracy of the information ' returned by this script ' *************** option explicit dim strComputer dim strDeviceID dim strDeviceName dim strID dim strURL dim intOpenIE dim bolIBM dim objWMI dim objBattery dim colBattery dim objShell dim colHWInfo dim objHWInfo strComputer = "."

strURL = "http://www.lenovo.com/batteryprogram"

Set objShell = Wscript.CreateObject("Wscript.Shell")

' Create WMI object

Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") ' Query WMi for vendor information Set colHWInfo = objWMI.ExecQuery("Select * from Win32_ComputerSystemProduct") bolIBM = False For Each objHWInfo in colHWInfo If objHWInfo.vendor = "IBM" Then bolIBM = True If objHWInfo.vendor = "Lenovo" Then bolIBM = True Next

' If system is not an IBM, exit

If bolIBM <> True Then

msgbox "Battery Test Unsuccessful: This test is intended for systems manufactured by IBM or " &amp; _ "Lenovo only",48, "Incompatible System"

wscript.quit

End If

Set colBattery = objWMI.ExecQuery("Select * from Win32_Battery") If colBattery.count = 0 Then intOpenIE = msgbox("Battery information could not be obtained for your system. " &amp; _ "This test is only intended for Notebook/Laptop systems. If your computer is a laptop/notebook system, " &amp; _ "press Yes to visit the Lenovo Battery Recall site for further instructions",20,"Battery Info Not Found") If intOpenIE = 6 Then objShell.run("IExplore.exe " &amp; strURL) wscript.quit End If For Each objBattery in colBattery strDeviceID = objBattery.DeviceID strDeviceName = objBattery.name If objCompare(strDeviceID) = "True" Then Match If objCompare(strDeviceName) = "True" Then Match Next msgbox "The battery installed in your system is not currently on the recall list. " &amp; _ "IT services will be conducting further testing and you will be notified of any changes.",64,"Battery Test Passed"

wscript.quit

Function objCompare(strID)

objCompare = "False"

If inStr(strID,"92P1072") > 0 Then objCompare = "True"

If inStr(strID,"92P1088") > 0 Then objCompare = "True"

If inStr(strID,"92P1142") > 0 Then objCompare = "True"

If inStr(strID,"92P1170") > 0 Then objCompare = "True"

If inStr(strID,"92P1174") > 0 Then objCompare = "True"

If inStr(strID,"92P1073") > 0 Then objCompare = "True"

If inStr(strID,"92P1089") > 0 Then objCompare = "True"

If inStr(strID,"92P1141") > 0 Then objCompare = "True"

If inStr(strID,"92P1169") > 0 Then objCompare = "True"

If inStr(strID,"93P5028") > 0 Then objCompare = "True"

If inStr(strID,"92P1173") > 0 Then objCompare = "True"

If inStr(strID,"93P5030") > 0 Then objCompare = "True"

End Function

Sub Match

intOpenIE = msgbox("The model number of the battery installed in your system " &amp; _ "matches a model number on the recall list. Please contact the Help Desk " &amp; _ "for instructions on how to replace your battery. " &amp; _ "If you wish to visit the Lenovo Battery recall page for instructions, click " &amp; _ "Yes.", 20, "Warning! Defective Battery Detected") If intOpenIE = 6 Then objShell.run("IExplore.exe " &amp; strURL) wscript.quit End Sub

Published Tuesday, October 03, 2006 12:18 PM by rodtrent

Comments

No Comments
Powered by Community Server (Commercial Edition), by Telligent Systems