In the Win2000 system, commands can be executed through 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 & "The status is: " & strStatus
response.write ".<br>" & replace(strPResult,vbCrLf,"<br>")
response.write "<br><hr>Written by Ci Qinqiang, welcome to visit
<a href='http://blog.csdn.net/cqq' target='_blank'>
http://blog.csdn.net/cqq</a>"
%>
In XP system or Windows.NET Server system, you can use WMI to achieve this,
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 Each result in PingResult
if clng(result.StatusCode)>0 then
response.write "offline"
else
response.write "online"
end if
Next
%>
Of course, we can also write corresponding components ourselves or use some ready-made components to achieve such functions,
so I won’t go into details here.