Advertisement
Guest User

Dennis de Vries

a guest
Jul 1st, 2009
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. Dim strWebsite
  2.  
  3. strWebsite = "www.nshispeed.nl/ifo/ifo/amsterdamcs"
  4.  
  5.  
  6. If PingSite( strWebsite ) Then
  7. exitCode = 0
  8. WScript.Quit (exitCode Mod 255)
  9.  
  10. Else
  11. exitCode = 1
  12. WScript.Quit (exitCode Mod 255)
  13.  
  14. End If
  15.  
  16.  
  17. Function PingSite( myWebsite )
  18. ' This function checks if a website is running by sending an HTTP request.
  19. ' If the website is up, the function returns True, otherwise it returns False.
  20. ' Argument: myWebsite [string] in "www.domain.tld" format, without the
  21. ' "http://" prefix.
  22. '
  23. ' Written by Rob van der Woude
  24. ' http://www.robvanderwoude.com
  25. Dim intStatus, objHTTP
  26.  
  27. Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
  28.  
  29. objHTTP.Open "GET", "http://" & myWebsite & "/", False
  30. objHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)"
  31.  
  32. On Error Resume Next
  33.  
  34. objHTTP.Send
  35. intStatus = objHTTP.Status
  36.  
  37. On Error Goto 0
  38.  
  39. If intStatus = 200 Then
  40. PingSite = True
  41. Else
  42. PingSite = False
  43. End If
  44.  
  45. Set objHTTP = Nothing
  46. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement