Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for issiteup.vbs

(view source code of issiteup.vbs as plain text)

  1. Dim strWebsite
  2.  
  3. strWebsite = "www.robvanderwoude.com"
  4.  
  5. If IsWebsiteUp( strWebsite ) Then
  6. 	WScript.Echo "Web site " & strWebsite & " is up and running!"
  7. Else
  8. 	WScript.Echo "Web site " & strWebsite & " is down!!!"
  9. End If
  10.  
  11.  
  12. Function IsWebsiteUp( myWebsite )
  13. ' This function checks if a website is running by sending an HTTP request.
  14. ' If the website is up, the function returns True, otherwise it returns False.
  15. ' Argument: myWebsite [string] in "www.domain.tld" format, without the
  16. ' "http://" prefix.
  17. '
  18. ' Written by Rob van der Woude
  19. ' http://www.robvanderwoude.com
  20. '
  21. ' The X-HTTP component is available at:
  22. ' http://www.xstandard.com/page.asp?p=C8AACBA3-702F-4BF0-894A-B6679AA949E6
  23. ' For more information on available functionality read:
  24. ' http://www.xstandard.com/printer-friendly.asp?id=32ADACB9-6093-452A-9464-9269867AB16E
  25. 	Dim objHTTP
  26.  
  27. 	Set objHTTP = CreateObject( "XStandard.HTTP" )
  28.  
  29. 	objHTTP.AddRequestHeader "User-Agent", _
  30. 	                         "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)"
  31. 	objHTTP.Get "http://" & myWebsite
  32.  
  33. 	If objHTTP.ResponseCode = 200 Then
  34. 		IsWebsiteUp = True
  35. 	Else
  36. 		IsWebsiteUp = False
  37. 	End If
  38.  
  39. 	Set objHTTP = Nothing
  40. End Function
  41.  

page last modified: 2024-04-16; loaded in 0.0094 seconds