My Stuff

My Collection of Useful Stuff

« PreviousNext »

Retrieve Warranty Information For Hp And Compaq Machines

7 January 2007

Retrieve Warranty Information For Hp And Compaq Machines
Description:

Author: Carlos

Description:

Retrieves warranty information for HP/COMPAQ machines

Script:‘====================
‘ WarrantyCheck

‘ WRITTEN BY: crodrig186@hotmail.com

‘ PURPOSE: This script can retrieve information from a HP/COMPAQ
‘ remote machine or the local host and can go to the
‘ HP/COMPAQ website and retrieve the warranty information

‘ OUTPUT: A single line of information with each field separated
‘ by a comma - designed to be easily appended to a CSV
‘ type file.

‘ NOTE: this script is fully functional and will work providing
‘ COMPAQ/HP does not update their website.

‘ LAST TESTED: 2/9/2006

‘ COMMENTS: Would you please comment about this script? Send me an e-mail
‘ with your feedback. comments and suggestions are always welcome.
‘ Additionally, would you kindly post your comments on the following
‘ link? Much appreciated
‘ http://cwashington.netreach.net/depo/view.asp?Index=1098&ScriptType=vbscript

‘ Thanks

‘======================

Dim strComputername, serialnumber, manu, name, model, ipad
Dim warrantyinfo, friendlyproduct, desc, liston

GetMachine
GetInformation
warrantyinfo = WarrantyCheck(serialnumber, model)
ShowInformation

WScript.Quit

sub GetMachine
strComputerName = InputBox(”Please enter the machine name you would” & VbCrLf & _
“like to target. Leave the period (.) to” & VbCrLf & _
“target this machine: “, “TARGET MACHINE”)
End Sub

Sub GetInformation
On Error Resume Next
strWinMgt = “winmgmts://” & strComputerName & “”
Set CompSysSet = GetObject(strWinMgt).ExecQuery(”select * from Win32_ComputerSystem”)

If Err.Number > 0 Then
ShowErr Err.Number
End If

For Each CompSys In CompSysSet
model = trim(CompSys.model)
manu = replace(Trim(CompSys.Manufacturer),”,”,” “)
name = Trim(CompSys.Name)
Next
Set CompSysSet = GetObject(strWinMgt).ExecQuery(”select * from Win32_BIOS”)
For Each CompSys In CompSysSet
serialnumber = CompSys.serialnumber
Next

Set objWMIService = GetObject(”winmgmts:\\” & strcomputername & “\root\cimv2″)
Set IPConfigSet = objWMIService.ExecQuery _
(”Select * from Win32_NetworkAdapterConfiguration”,,48)
For Each IPConfig In IPConfigSet
If instr(lcase(IPConfig.DNSDomain),THISDOMAIN) > 0 Then
for Each IPValue in IPConfig.IPAddress
ipad = IPValue
Next
End If
Next

Set strWinMgt = Nothing
Set objWMIService = Nothing

End Sub

Sub ShowErr (err_number)
Select Case err_number
Case 462
WScript.Echo “TARGET machine <" & strComputername & "> is unavailable!” & VbCrLf & _
“Please check the IP address or ” &_
“machine name and try again”
Case Else
End Select
WScript.Quit
End Sub

Sub ShowInformation
WScript.Echo Trim(UCase(name)) & “,” & Trim(manu) & “,” & trim(ucase(replace(model,”%23″,”#”))) & _
“{” & friendlyproduct & “},” & Trim(serialnumber) & “,” & Trim(warrantyinfo) & _
“, IP: ” & ipad
End Sub

Function WarrantyCheck(serialnumber, ByVal model)
pn = “”
If model = “Not needed” Then
model = “”
End If

If Len(trim(serialnumber)) <= 10 Then
pn = trim(Whatstheproductnumber(model))
Else
pn = ""
End If
Dim hugeArr, minfo
Dim returnStr, strInfo

sn = serialnumber
url = “http://h20000.www2.hp.com/bizsupport/TechSupport/WarrantyResults.jsp?lang=en&cc=us&prodSeriesId=96266&prodTypeId=12454&sn=” & sn & “&pn=” & pn & “&country=US&nickname=&find=Display+Warranty+Information+%C2%BB”
Set objHTTP = CreateObject(”MSXML2.XMLHTTP”)

Call objHTTP.Open(”GET”, url, FALSE)
objHTTP.Send
returnStr = objHTTP.ResponseText

product_friend = InStr(returnStr, “Product description”) + Len(”Product description”)
eo_friendlyproduct = InStr(Mid(returnStr,product_friend+5,80),” “,”"),” ”
int_date_is_here = InStr(str_i, str_date_placer)
str_date_of_warranty = Mid(str_i, int_date_is_here + Len(str_date_placer), 11)

‘— look for strings ‘Active’ or ‘Expired’
int_isactive = 0
int_isactive = InStrRev(str_i,”>Active<")

str_warranty = IIF(int_isactive > 0, “ACTIVE - Ends on: “, “EXPIRED - Ended on: “)
WarrantyCheck = “Status: ” & str_warranty & str_date_of_warranty
End Function

Function Whatstheproductnumber(modelin)
modelin = Trim(Replace(modelin,”(”,” “))
modelin = Trim(Replace(modelin,”)”,” “))
If InStr(modelin, ” “) > 0 Then
modelin = Mid(modelin, InStrRev(modelin,” “))
End If
If InStr(modelin, “#”) > 0 Then
modelin = Replace(modelin, “#”, “%23″)
End If
Whatstheproductnumber= modelin

End Function

Function IIF(expr, truepart, falsepart)
If expr Then
IIF = truepart
Else
IIF = falsepart
End If
End Function

Posted in Scripting, General | Trackback | del.icio.us | Top Of Page

Comments are closed.