Executes the ping command in ASP and returns the result
In a Win2000 system, commands can be executed by the Exec method of the Wscript.Shell object,
The simple code is as follows:
<% Response.Buffer = True%>
<%
url = "Www.topronet.com"
Set Objwshell = CreateObject ("Wscript.Shell")
Set objcmd = objwshell.exec ("ping" & URL)
Strpresult = ObjCmd.StdOut.Readall ()
Set objcmd = Nothing:set Objwshell = Nothing
strstatus = "Offline"
If InStr (Strpresult, "ttl=") >0 then strstatus = "Online"
Response.Write URL & "status is:" & strstatus
Response.Write ".<br>" & Replace (Strpresult,vbcrlf, "<br>")
Response.Write "<br>
target= ' _blank ' >http://blog.csdn.net/cqq</a> '
%>
In XP or Windows.NET server systems, WMI can be used to implement the
The code is as follows:
<%
url = "Www.topronet.com"
WMI = "Winmgmts:{impersonationlevel=impersonate}"
Wqlquery = "Select StatusCode from Win32_PingStatus WHERE Address" & _
"= '" & URL & "'"
Set pingresult = GetObject (WMI). ExecQuery (Wqlquery, "WQL", 48)
Response.Write URL & "Status"
For Pingresult
If CLng (result. StatusCode) >0 Then
Response.Write "Offline"
Else
Response.Write "Online"
End If
Next
%>
Of course, we can also write the appropriate components ourselves or use some ready-made components to achieve this function,
There's not much to say here.