[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 yu2n 于 2015-4-27 16:54 编辑
  1. ' Ping 判断网络是否联通
  2. Function Ping(host)
  3.   If CreateObject("WScript.Shell").Run("cmd /c ping -n 1 -w 500 " & host, 0, True) = 0 Then
  4.     Ping = True
  5.   Else
  6.     Ping = False
  7.   End If
  8. End Function
复制代码
  1. ' Ping 判断网络是否联通
  2. Function Ping(host)
  3.   On Error Resume Next
  4.   Ping=False : If (host="") Then Exit Function
  5.   For Each o in GetObject("winmgmts:").ExecQuery _
  6.    ("select * from Win32_PingStatus where address='" & host & "' and timeout=500")
  7.     If (o.ResponseTime>=0) Then Ping=True : Exit For
  8.   Next
  9. End Function
复制代码
用法:
  1. If Ping("www.baidu.com") Then
  2. Msgbox "外网通。"
  3. Else
  4. Msgbox "外网不通。"
  5. End If
复制代码
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

返回列表