This subroutine will ping a server based on an IP address and output the returned data to a text file. It will then parse the text file, and output the information to the user's browser.
By default the function pings the user, by getting the browser's IP address (Request.ServerVariables("REMOTE_ADDR")). You can change this to whatever you want, or even specify the host string as a parameter.
Sub Ping()
strHost = Request.ServerVariables("REMOTE_ADDR")
response.write "Pinging "&strHost&" with 32 bytes of data.......<BR>"
Set oShell = Server.CreateObject ("Wscript.Shell")
oShell.Run "%ComSpec% /c ping " & strHost & ">C:\" & strHost & ".txt",0,true
Set oFS = Server.CreateObject("Scripting.FileSystemObject ")
Set oTF = oFS.OpenTextFile("C:\" & strHost & ".txt")
tempData = Null
Data = Null
i = 0
Do While Not oTF.AtEndOfStream
Data = Trim(oTF.Readline )
IF i > 2 Then
tempData = tempData & Data & "<BR>"
End IF
i = (i + 1)
Loop
oTF.Close
oFS.DeleteFile "C:\" & strHost & ".txt"
Set oFS = Nothing
response.write tempData
end sub