最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
在ASP中执行Ping命令,并且返回结果
时间:2022-07-02 23:36:15 编辑:袖梨 来源:一聚教程网
在ASP中执行Ping命令,并且返回结果
在Win2000系统中,可以通过Wscript.Shell对象的Exec方法执行命令,
简单的代码如下:
<% 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 = "离线"
if InStr(strPResult,"TTL=")>0 then strStatus = "在线"
response.write url & " 状态为: " & strStatus
response.write ".
" & replace(strPResult,vbCrLf,"
")
response.write "
慈勤强编写,欢迎访问target='_blank'>http://blog.111com.net/cqq"
%>
在XP系统或者Windows.NET Server系统中,可以使用WMI来实现,
代码如下:
<%
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 & " 状态 "
For Each result in PingResult
if clng(result.StatusCode)>0 then
response.write "离线"
else
response.write "在线"
end if
Next
%>
当然,我们也可以自己编写相应的组件或者使用一些现成的组件来实现这样的功能,
这里就不多说了。
在Win2000系统中,可以通过Wscript.Shell对象的Exec方法执行命令,
简单的代码如下:
<% 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 = "离线"
if InStr(strPResult,"TTL=")>0 then strStatus = "在线"
response.write url & " 状态为: " & strStatus
response.write ".
" & replace(strPResult,vbCrLf,"
")
response.write "
慈勤强编写,欢迎访问target='_blank'>http://blog.111com.net/cqq"
%>
在XP系统或者Windows.NET Server系统中,可以使用WMI来实现,
代码如下:
<%
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 & " 状态 "
For Each result in PingResult
if clng(result.StatusCode)>0 then
response.write "离线"
else
response.write "在线"
end if
Next
%>
当然,我们也可以自己编写相应的组件或者使用一些现成的组件来实现这样的功能,
这里就不多说了。
相关文章
- 《晶核》团本奖励领取如何 06-16
- 热门2025币圈十大全球交易所加密货币排行-最省钱现货交易平台币安推荐 06-16
- 《艾塔纪元》武器升级怎么样 06-16
- DYθR 创始人深度剖析:解密代币价格涨跌背后的群体行为密码 06-16
- 最新正规全球交易所2025数字资产交易榜单-最安全虚拟币交易app币安推荐 06-16
- 《空之要塞:启航》完美链接第四十一关怎么通关最快 06-16