Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getWebPage(sURL)
- dim iErrorCount
- on error resume next
- '******************
- 'ERROR CHECKING OFF
- '******************
- oHTTP.Open "GET", sURL, False
- oHTTP.Send
- if (err.number <> 0) then
- iErrorCount = 0
- do
- iErrorCount = iErrorCount + 1
- log "log.txt", "Error retrieving Web page. Error #0x" & hex(err.number) & ". Description: " & err.description, 0, true
- if (iErrorCount = 5) then
- log "log.txt", vbTab & "Five successive errors retrieving Web page. Exiting...", 1, true
- msgbox "ERROR: Five successive errors retrieving " & chr(34) & sURL & chr(34) & vbCRLF & vbCRLF & "See the log file for details." & vbCRLF & vbCRLF & "Exiting...", vbOkOnly, programName
- log "last result.html", oHTTP.ResponseText, 0, false
- wscript.quit
- else
- wscript.sleep iErrorCount * 60000
- set oHTTP = nothing
- set oHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
- oHTTP.Open "GET", sURL, False
- oHTTP.Send
- end if
- loop until (err.number = 0)
- end if
- on error goto 0
- '*****************
- 'ERROR CHECKING ON
- '*****************
- if (oHTTP.Status <> 200) then
- log "log.txt", vbcrlf & vbtab & "Error retrieving Web page" & vbcrlf & vbtab & "URL: " & sURL & vbcrlf & vbtab & "Status: " & oHTTP.Status & vbcrlf & vbtab & "Description: " & oHTTP.statusText, 1, true
- msgbox "ERROR: Cannot retrieve Web page." & vbCRLF & vbCRLF & "See the log file for details." & vbCRLF & vbCRLF & "Exiting...", vbOkOnly, programName
- wscript.quit
- else
- ' log "last result.html", oHTTP.ResponseText, 0, false
- getWebPage = oHTTP.ResponseText
- end if
- end function
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set Outp = Wscript.Stdout
- On Error Resume Next
- Set File = WScript.CreateObject("Microsoft.XMLHTTP")
- File.Open "GET", "ftp://ftp.microsoft.com/Softlib/README.TXT", False
- File.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C; .NET4.0E; BCD2000; BCD2000)"
- File.Send
- If err.number <> 0 then
- line =""
- Line = Line & vbcrlf & ""
- Line = Line & vbcrlf & "Error getting file"
- Line = Line & vbcrlf & "=================="
- Line = Line & vbcrlf & ""
- Line = Line & vbcrlf & "Error " & err.number & "(0x" & hex(err.number) & ") " & err.description
- Line = Line & vbcrlf & "Source " & err.source
- Line = Line & vbcrlf & ""
- Line = Line & vbcrlf & "HTTP Error " & File.Status & " " & File.StatusText
- Line = Line & vbcrlf & File.getAllResponseHeaders
- wscript.echo Line
- Err.clear
- wscript.quit
- End If
- On Error Goto 0
- Set BS = CreateObject("ADODB.Stream")
- BS.type = 1
- BS.open
- BS.Write File.ResponseBody
- BS.SaveToFile "c:userssafetyscanner.exe", 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement