zoukankan      html  css  js  c++  java
  • “ping某个IP地址,如果ping不通则在dos窗口或弹出MsgBox提示原因”的批处理bat命令

    “ping某个IP地址,如果ping不通则在dos窗口提示原因”的批处理bat命令

    @echo off&setlocal enabledelayedexpansion
    title Ping检测批处理
    mode con cols=88 lines=5&color 0a
    ::设置要ping的ip地址
    set ip=192.168.0.105
    
    ::设置要ping的次数
    set num=3
    
    echo,&echo 正在对 %ip% 进行 Ping检测,总检测次数为 %num% 次,请耐心等待。。。
    set count=%num%
    for /l %%a in (1,1,%num%) do (
        title 正在进行第 %%a 次 Ping检测。。。
        ping 127.1 -n "2">nul
        for /f "tokens=4 delims== " %%b in ('ping %ip% -n "1" ^| findstr /c:"平均"') do set ms=%%b
        if not defined ms (
            echo 第 %%a 次 ping 检测失败。
            set /a count-=1
        ) else (
            set /a pms+=!ms:~,-2!
        )
    )
    cls&echo,&echo 本次 Ping 检测记录了 !count! 次数据,正在计算平均值,请稍等。。。
    if not defined pms set msg=网络连接超时,请联系网络管理员。&goto End
    set /a ms=!pms!/!count!
    if %ms% leq 50 set msg=网络良好。如果还是卡,请联系网络运营商客服反馈。&goto End
    if %ms% geq 60 set msg=网络延迟,请联系网络管理员。&goto End
    exit
    :End
    if !count! lss %num% (
        set /a TO=!num!-!count!
        set color=color 0c
        set timeout=(警告:此次检测有 !TO! 次连接超时。)
    ) else (
        set color=color 0a
    )
    
    title Ping检测 -- 检测结果(共检测 %num% 次)
    ping 127.1 -n "4">nul
    cls&%color%&echo,&echo %msg%%timeout%
    echo,&echo 请按任意键退出脚本。
    pause>nul&exit

    “ping某个IP地址,如果ping不通则弹出MsgBox提示原因”的批处理bat命令

    @echo off&setlocal enabledelayedexpansion
    title Ping检测批处理
    mode con cols=88 lines=5&color 0a
    ::设置要ping的ip地址
    set ip=192.168.0.104
    
    ::设置要ping的次数
    set num=3
    
    echo,&echo 正在对 %ip% 进行 Ping检测,总检测次数为 %num% 次,请耐心等待。。。
    set count=%num%
    for /l %%a in (1,1,%num%) do (
        title 正在进行第 %%a 次 Ping检测。。。
        ping 127.1 -n "2">nul
        for /f "tokens=4 delims== " %%b in ('ping %ip% -n "1" ^| findstr /c:"平均"') do set ms=%%b
        if not defined ms (
            echo 第 %%a 次 ping 检测失败。
            set /a count-=1
        ) else (
            set /a pms+=!ms:~,-2!
        )
    )
    cls&echo,&echo 本次 Ping 检测记录了 !count! 次数据,正在计算平均值,请稍等。。。
    if not defined pms echo msgbox "网络连接超时,请联系网络管理员。",64,"提示">alert.vbs && start alert.vbs && ping -n 2 127.1>nul && del alert.vbs &goto End
    set /a ms=!pms!/!count!
    if %ms% leq 50 set msg=网络良好。如果还是卡,请联系网络运营商客服反馈。 &goto End
    if %ms% geq 60 echo msgbox "网络延迟,请联系网络管理员。",64,"提示">alert.vbs && start alert.vbs && ping -n 2 127.1>nul && del alert.vbs &goto End
    exit
    :End
    if !count! lss %num% (
        set /a TO=!num!-!count!
        set color=color 0c
        set timeout=(警告:此次检测有 !TO! 次连接超时。)
    ) else (
        set color=color 0a
    )
    
    title Ping检测 -- 检测结果(共检测 %num% 次)
    ping 127.1 -n "4">nul
    cls&%color%&echo,&echo %msg%%timeout%
    echo,&echo 请按任意键退出脚本。
    pause>nul&exit
  • 相关阅读:
    Atitit.500 503 404错误处理最佳实践oak
    Atitit. 解决unterminated string literal 缺失引号
    Atitit. Java script 多重多重catch语句的实现and Javascript js 异常机制
    Atitit. Dwr 抛出异常error解决方案
    Atitit.js javascript异常处理机制与java异常的转换.js exception process Voae
    Atitit.软件gui按钮and面板---通讯子系统(区)-- github 的使用....
    atitit。gui 界面皮肤以及换肤总结 java .net c++
    atitit.软件开发GUI 布局管理优缺点总结java swing wpf web html c++ qt php asp.net winform
    atitit.报表最佳实践oae 与报表引擎选型
    Atitit. 软件---多媒体区---- jmf 2.1.1 Java Media Framework 支持的格式
  • 原文地址:https://www.cnblogs.com/rainbow70626/p/7481378.html
Copyright © 2011-2022 走看看