0514-86177077
9:00-17:00(工作日)
對于vbs中ping的實現可以通過兩種方式 :
1、調用系統ping命令
Set wshell = CreateObject("WScript.Shell") wshell.run("ping 182.183.101.1",0.true)
對于以上調用,如果想對其進行過濾,可以考慮將運行結果重定向到文件,在讀到一個string中,查找其中是否有timeout或超時字符,判斷是否超時。本打算直接拼接命令重定向到文件,但怎么都不成功,所以run調用一個bat,bat中寫:ping 192.168.101.1 -n 1 -w 1200
2、使用wmi查詢pingstate類處理:
'url = "www.baidu.com" url = "119.75.217.109" strComputer = "." Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" strComputer "\root\cimv2") Set colPings = objWMIService.ExecQuery ("Select * From Win32_PingStatus where Address = '" url "'") For Each objPing in colPings MsgBox url " responded to ping." vbcrlf _ "Responding Address: " objPing.ProtocolAddress vbcrlf _ "Responding Name: " objPing.ProtocolAddressResolved vbcrlf _ "Bytes Sent: " objPing.BufferSize vbcrlf _ "Time: " objPing.ResponseTime " ms" Next
到此這篇關于vbs ping的實現示例的文章就介紹到這了,更多相關vbs ping內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!
標簽:湖州 鶴壁 四平 文山 銅川 邢臺 西安 海口
上一篇:ActiveX部件不能創建對象:dm.dmsoft代碼:800A01AD
下一篇:vbs小程序圖標更改方法的實現
Copyright ? 1999-2012 誠信 合法 規范的巨人網絡通訊始建于2005年
蘇ICP備15040257號-8