home *** CD-ROM | disk | FTP | other *** search
- ' ***************************************************************
- ' * GetHTTP.vbs *
- ' * By Vittorio Pavesi (www.vittorio.tk) *
- ' * *
- ' * Simulate an HTTP Get and return time information *
- ' ***************************************************************
-
- CheckHost("http://www.vittorio.tk")
-
- Sub CheckHost(host)
- dim startdate
- Dim objXmlHttp
- Dim strHTML
- Set objXmlHttp = CreateObject("Msxml2.ServerXMLHTTP")
-
- lResolve = 1 * 1000
- lConnect = 5 * 1000
- lSend = 10 * 1000
- lReceive = 10 * 1000
-
- objXmlHttp.setTimeouts lResolve, lConnect, lSend, lReceive
-
- startdate = now
- t1 = timer
- objXmlHttp.open "GET", host , False
- objXmlHttp.send
-
- if Err.number = 0 and objXmlHttp.status = 200 then
- Result = "OK"
- 'objXmlHttp.responseText
- else
- Result = "Error"
- end if
- t2 = timer
- Set objXmlHttp = Nothing
- wscript.echo "Host: " & host & vbcrlf & "StartTime: " & startdate & vbcrlf & "Result: " & Result & vbcrlf & "Response Time: " & TimeDiff(t2,t1) & "msec"
- End sub
-
- Function TimeDiff(iEnd, iStart)
- ' returns time diff in milliseconds
- Dim iReturn
- iReturn = iEnd - iStart
- If iReturn < 0 Then iReturn = iEnd - iStart + (60*60*24)
- TimeDiff = 1000 * iReturn
- End Function