jcunews

WebCheck.vbs

Dec 2nd, 2020 (edited)
629
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'WebCheck.vbs - Check website and/or resource availability.
  2. 'https://www.reddit.com/u/jcunews1
  3. 'https://pastebin.com/u/jcunews
  4. 'https://greasyfork.org/en/users/85671-jcunews
  5.  
  6. 'timeout in milliseconds (1 second = 1000ms).
  7. 'for name resolving, site connection, request sending, response waiting.
  8. timeout = 10000
  9.  
  10. if wscript.arguments.count = 0 then
  11.   wscript.echo "Usage: WebCheck {url}" & vbcrlf & vbcrlf & "Exit codes:" & _
  12.    vbcrlf & "100-299 = Site and resource are accessible." & _
  13.     vbcrlf & "300-399 = Site is accessible, unknown resource availability." & _
  14.     vbcrlf & "400-499 = Site is accessible, resource is not found." & _
  15.     vbcrlf & "500-599 = Site error, unknown resource accessibility." & _
  16.     vbcrlf & "1000    = Site not found, or service is unavailable." & _
  17.     vbcrlf & "2000    = Invalid URL."
  18.   wscript.quit
  19. end if
  20. set ht = createobject("winhttp.winhttprequest.5.1")
  21. ht.settimeouts timeout, timeout, timeout, timeout
  22. on error resume next
  23. ht.open "HEAD", wscript.arguments(0), false
  24. if err.number <> 0 then
  25.   wscript.echo err.description
  26.   wscript.quit 2000
  27. end if
  28. ht.send
  29. if err.number <> 0 then
  30.   wscript.echo err.description
  31.   wscript.quit 1000
  32. else
  33.   wscript.echo err.statustext
  34.   wscript.quit ht.status
  35. end if
  36.  
RAW Paste Data