This is handy for a
up to 20 or 30 checks at a time. It could be cumbersome after that . This is a
modification to a solution posted by Rob Sampson in Experts Exchange.
strAssets =
"Assets.txt"
strOutput =
"AssetWarranties.csv"
Set objFSO =
CreateObject("Scripting.FileSystemObject")
Const intForReading
= 1
Set objInput =
objFSO.OpenTextFile(strAssets, intForReading, False)
Set objOutput =
objFSO.CreateTextFile(strOutput, True)
objOutput.WriteLine
"""Serial"",""Status"",""Telephone
Support"",""Expiry"",""Hardware
Support"",""Expiry"""
Set objFile =
objFSO.CreateTextFile("output.xml", True)
While Not
objInput.AtEndOfStream
strSerial
= Trim(objInput.ReadLine)
If
strSerial <> "" Then
Set
objIE = CreateObject("InternetExplorer.Application")
objIE.Visible
= True
objIE.Navigate
strSite
While
objIE.ReadyState <> 4 Or objIE.Busy
WScript.Sleep
100
Wend
objIE.document.getElementByID("sn").Value
= strSerial
objIE.document.getElementByID("warrantycheckbutton").Click()
While
InStr(objIE.Document.body.InnerHTML, "registration-text") = 0 And _
InStr(objIE.Document.body.InnerHTML,
"phone-text") = 0 And _
InStr(
objIE.Document.body.InnerHTML,
"hardware-text") = 0
WScript.Sleep
30000
Wend
'Pause
to Load Page Pully
wscript.ECHO
"Press Return when page fully loads. DO NOT PRESS OK UNTIL IT DOES "
strPageText
= objIE.Document.body.InnerHTML
objFile.WriteLine
strPageText
objIE.Quit
If
InStr(strPageText, "serial number is not valid") > 0 Then
'WScript.Echo
"Serial number is not valid"
objOutput.WriteLine
"""" & strSerial &
""",""Serial number is not valid"""
Else
strDetail
= """" & strSerial & """"
If
InStr(strPageText, "registration-true") > 0 Then
'WScript.Echo
"Valid Purchase Date"
strDetail
= strDetail & ",""Valid Purchase Date"""
Else
'WScript.Echo
"Purchase Date not Validated"
strDetail
= strDetail & ",""Purchase Date not
Validated"""
End
If
If
InStr(strPageText, "warrantyPage.warrantycheck.displayPHSupportInfo(
true") > 0 Then
'WScript.Echo
"Telephone Technical Support: Active"
strDetail
= strDetail & ",""Telephone Technical Support:
Active"""
intPos
= InStr(InStr(strPageText,
"warrantyPage.warrantycheck.displayPHSupportInfo( true"),
strPageText, "Estimated Expiration Date: ")
'wscript.echo
intpos
intpos
= intpos + 26
intposend
= InStr(intPos, strPageText, "<br/>")
intStrLen
= intposend - intpos
strExpiration
= Mid(strPageText,intPos,intStrLen)
If
intPos > 0 Then
strExpiration
= Mid(strPageText,intPos,intStrLen)
'WScript.Echo
strExpiration
strDetail
= strDetail & ",""" & strExpiration &
""""
Else
'WScript.Echo
"Estimated Expiration Date: UNKNOWN"
strDetail
= strDetail & ",""Estimated Expiration Date:
UNKNOWN"""
End
If
Else
'WScript.Echo
"Telephone Technical Support: Expired"
strDetail
= strDetail & ",""Telephone Technical Support:
Expired"","
End
If
If
InStr(strPageText,
"warrantyPage.warrantycheck.displayHWSupportInfo(true") > 0 Then
'WScript.Echo
"Repairs and Service Coverage: Active"
strDetail
= strDetail & ",""Repairs and Service Coverage:
Active"""
intPos
= InStr(InStr(strPageText,
"warrantyPage.warrantycheck.displayHWSupportInfo(true"), strPageText,
"Estimated Expiration Date: ")
intpos
= intpos + 26
intposend
= InStr(intPos, strPageText, "<br/>")
intStrLen
= intposend - intpos
If
intPos > 0 Then
strExpiration
= Mid(strPageText,intPos,intStrLen)
'strExpiration
= Mid(strPageText, intPos, InStr(intPos, strPageText, "<BR>") -
intPos)
'WScript.Echo
strExpiration
strDetail
= strDetail & ",""" & strExpiration &
""""
Else
'WScript.Echo
"Estimated Expiration Date: UNKNOWN"
strDetail
= strDetail & ",""Estimated Expiration Date:
UNKNOWN"""
End
If
Else
'WScript.Echo
"Repairs and Service Coverage: Not Active"
strDetail
= strDetail & ",""Repairs and Service Coverage: Not
Active"""
End
If
objOutput.WriteLine
strDetail
End
If
End
If
Wend
objInput.Close
objOutput.Close
WScript.Echo
"Done"