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
  • 相关阅读:
    前端布局方式汇总及概念浅析
    html中map area 热区自适应的原生js实现方案
    css3实现背景颜色渐变,文字颜色渐变,边框颜色渐变
    css3动画的性能优化_针对移动端卡顿问题
    分享几个很实用的CSS技巧对前端技术很有帮助
    为什么是link-visited-hover-active原理这样的特殊
    HTML中<base>标签的正确使用
    面试WEB前端如何才能通过?
    Java连载48-final关键字
    Python连载48-正则表达式(中)
  • 原文地址:https://www.cnblogs.com/rainbow70626/p/7481378.html
Copyright © 2011-2022 走看看