Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. function getWebPage(sURL)
  2. dim iErrorCount
  3.  
  4. on error resume next
  5. '******************
  6. 'ERROR CHECKING OFF
  7. '******************
  8. oHTTP.Open "GET", sURL, False
  9. oHTTP.Send
  10.  
  11. if (err.number <> 0) then
  12. iErrorCount = 0
  13.  
  14. do
  15. iErrorCount = iErrorCount + 1
  16.  
  17. log "log.txt", "Error retrieving Web page. Error #0x" & hex(err.number) & ". Description: " & err.description, 0, true
  18.  
  19. if (iErrorCount = 5) then
  20. log "log.txt", vbTab & "Five successive errors retrieving Web page. Exiting...", 1, true
  21. msgbox "ERROR: Five successive errors retrieving " & chr(34) & sURL & chr(34) & vbCRLF & vbCRLF & "See the log file for details." & vbCRLF & vbCRLF & "Exiting...", vbOkOnly, programName
  22.  
  23. log "last result.html", oHTTP.ResponseText, 0, false
  24.  
  25. wscript.quit
  26. else
  27. wscript.sleep iErrorCount * 60000
  28.  
  29. set oHTTP = nothing
  30. set oHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0")
  31.  
  32. oHTTP.Open "GET", sURL, False
  33. oHTTP.Send
  34. end if
  35. loop until (err.number = 0)
  36. end if
  37. on error goto 0
  38. '*****************
  39. 'ERROR CHECKING ON
  40. '*****************
  41.  
  42. if (oHTTP.Status <> 200) then
  43. 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
  44. msgbox "ERROR: Cannot retrieve Web page." & vbCRLF & vbCRLF & "See the log file for details." & vbCRLF & vbCRLF & "Exiting...", vbOkOnly, programName
  45.  
  46. wscript.quit
  47. else
  48. ' log "last result.html", oHTTP.ResponseText, 0, false
  49. getWebPage = oHTTP.ResponseText
  50. end if
  51. end function
  52.  
  53. Set fso = CreateObject("Scripting.FileSystemObject")
  54. Set Outp = Wscript.Stdout
  55. On Error Resume Next
  56. Set File = WScript.CreateObject("Microsoft.XMLHTTP")
  57. File.Open "GET", "ftp://ftp.microsoft.com/Softlib/README.TXT", False
  58. 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)"
  59. File.Send
  60. If err.number <> 0 then
  61. line =""
  62. Line = Line & vbcrlf & ""
  63. Line = Line & vbcrlf & "Error getting file"
  64. Line = Line & vbcrlf & "=================="
  65. Line = Line & vbcrlf & ""
  66. Line = Line & vbcrlf & "Error " & err.number & "(0x" & hex(err.number) & ") " & err.description
  67. Line = Line & vbcrlf & "Source " & err.source
  68. Line = Line & vbcrlf & ""
  69. Line = Line & vbcrlf & "HTTP Error " & File.Status & " " & File.StatusText
  70. Line = Line & vbcrlf & File.getAllResponseHeaders
  71. wscript.echo Line
  72. Err.clear
  73. wscript.quit
  74. End If
  75.  
  76. On Error Goto 0
  77.  
  78. Set BS = CreateObject("ADODB.Stream")
  79. BS.type = 1
  80. BS.open
  81. BS.Write File.ResponseBody
  82. BS.SaveToFile "c:userssafetyscanner.exe", 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement