'Symantec AntiVirus updater script. Const WEB_PAGE = "http://securityresponse.symantec.com/avcenter/download/pages/US-N95.html" Const LINK_TEXT = "-i32.exe 0 Then SaveWebBinary = False Set web = Nothing Exit Function End If If web.Status <> "200" Then SaveWebBinary = False Set web = Nothing Exit Function End If varByteArray = web.ResponseBody Set web = Nothing 'Now save the file with any available method On Error Resume Next Set ado = Nothing Set ado = CreateObject("ADODB.Stream") If ado Is Nothing Then Set fs = CreateObject("Scripting.FileSystemObject") Set ts = fs.OpenTextFile(strFile, ForWriting, True) strData = "" strBuffer = "" For lngCounter = 0 to UBound(varByteArray) ts.Write Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1))) Next ts.Close Else ado.Type = adTypeBinary ado.Open ado.Write varByteArray ado.SaveToFile strFile, adSaveCreateOverWrite ado.Close End If SaveWebBinary = True End Function Function MakeAbsolute(strHref, strCurrentPage) 'Converts strHref from root or relative link to absolute link. 'strCurrentPage MUST be an absolute URL. Dim strMakeAbsolute, strRoot 'Set up working variables strMakeAbsolute = strHref strRoot = strCurrentPage 'Is it already absolute? If Left(strMakeAbsolute, 7) = "http://" Then MakeAbsolute = strMakeAbsolute Exit Function End If 'Figure out what the root page is If InStr(8, strRoot, "/") <> 0 Then 'Make the root so it DOES NOT have a trailing slash strRoot = Left(strRoot, InStr(8, strRoot, "/") - 1) End If 'Is a root reference used? If Left(strMakeAbsolute, 1) = "/" Then MakeAbsolute = strRoot & strMakeAbsolute Exit Function End If 'A relative link is used (it must be at this point!) MakeAbsolute = Left(strCurrentPage, InStrRev(strCurrentPage, "/")) & strMakeAbsolute End Function Function GetHrefBeforeMarker(strPage, strMarker) Dim strUrl Dim lngMarker Dim strPeekText lngMarker = InStr(strPage, strMarker) 'Make sure the marker exists If lngMarker = 0 Then GetHrefBeforeMarker = "" Exit Function End If 'Trim everything after the marker strPeekText = Left(strPage, lngMarker) 'See if an "a" tag exists If InStrRev(strPeekText, "") = 0 Then 'The marker is INSIDE the URL we are looking for. Push it to the end of the tag. lngMarker = InStr(lngMarker, strPage, ">") End If 'Now we have a marker at or after the end of an "a" tag 'Trim everything past the marker strUrl = Left(strPage, lngMarker) 'Trim everything before the href tag strUrl = Mid(strUrl, InStrRev(strUrl, "href=", Len(strUrl), vbTextCompare) + 5) 'If we have quotes, use them If Left(strUrl, 1) = Chr(34) Then strUrl = Mid(strUrl, 2) If InStr(strUrl, Chr(34)) <> 0 Then strUrl = Left(strUrl, InStr(strUrl, Chr(34)) - 1) 'If we have apostrophes, use them instead of quotes If Left(strUrl, 1) = "'" Then strUrl = Mid(strUrl, 2) If InStr(strUrl, "'") <> 0 Then strUrl = Left(strUrl, InStr(strUrl, "'") - 1) 'We might have a leading space. Not sure how, but trim to be safe. strUrl = Trim(strUrl) 'Trim everything past the first tag end If InStr(strUrl, ">") <> 0 Then strUrl = Left(strUrl, InStr(strUrl, ">") - 1) 'Trim everything past the first space If InStr(strUrl, " ") <> 0 Then strUrl = Left(strUrl, InStr(strUrl, " ")) 'Trim everything past the first tab If InStr(strUrl, vbTab) <> 0 Then strUrl = Left(strUrl, InStr(strUrl, vbTab)) 'That should be all! GetHrefBeforeMarker = strUrl End Function Sub Status(strMessage) If Lcase(Right(Wscript.FullName, 12)) = "\cscript.exe" Then Wscript.Echo strMessage End If End Sub