<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      在ASP中執行Ping命令,并且返回結果

      [摘要]在Win2000系統中,可以通過Wscript.Shell對象的Exec方法執行命令,簡單的代碼如下:<% Response.Buffer = true %> <% url = "www.topronet.com" Set objWShell...

      在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 ".<br>" & replace(strPResult,vbCrLf,"<br>")
          response.write "<br><hr>慈勤強編寫,歡迎訪問<a

      target='_blank'>http://blog.csdn.net/cqq</a>"
      %>

       

      在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
      %>


      當然,我們也可以自己編寫相應的組件或者使用一些現成的組件來實現這樣的功能,

      這里就不多說了。




      日韩精品一区二区三区高清