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

@echo off&setlocal enabledelayedexpansion
title Ping检测批处理
mode con cols= lines=&color 0a
::设置要ping的ip地址
set ip=192.168.0.105 ::设置要ping的次数
set num= echo,&echo 正在对 %ip% 进行 Ping检测,总检测次数为 %num% 次,请耐心等待。。。
set count=%num%
for /l %%a in (,,%num%) do (
title 正在进行第 %%a 次 Ping检测。。。
ping 127.1 -n "">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-=
) else (
set /a pms+=!ms:~,-!
)
)
cls&echo,&echo 本次 Ping 检测记录了 !count! 次数据,正在计算平均值,请稍等。。。
if not defined pms set msg=网络连接超时,请联系网络管理员。&goto End
set /a ms=!pms!/!count!
if %ms% leq set msg=网络良好。如果还是卡,请联系网络运营商客服反馈。&goto End
if %ms% geq 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 "">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= lines=&color 0a
::设置要ping的ip地址
set ip=192.168.0.104 ::设置要ping的次数
set num= echo,&echo 正在对 %ip% 进行 Ping检测,总检测次数为 %num% 次,请耐心等待。。。
set count=%num%
for /l %%a in (,,%num%) do (
title 正在进行第 %%a 次 Ping检测。。。
ping 127.1 -n "">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-=
) else (
set /a pms+=!ms:~,-!
)
)
cls&echo,&echo 本次 Ping 检测记录了 !count! 次数据,正在计算平均值,请稍等。。。
if not defined pms echo msgbox "网络连接超时,请联系网络管理员。",,"提示">alert.vbs && start alert.vbs && ping -n 127.1>nul && del alert.vbs &goto End
set /a ms=!pms!/!count!
if %ms% leq set msg=网络良好。如果还是卡,请联系网络运营商客服反馈。 &goto End
if %ms% geq echo msgbox "网络延迟,请联系网络管理员。",,"提示">alert.vbs && start alert.vbs && ping -n 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 "">nul
cls&%color%&echo,&echo %msg%%timeout%
echo,&echo 请按任意键退出脚本。
pause>nul&exit

最新文章

  1. BZOJ3198[SDOI2013]SPRING
  2. MsChart在MVC下的问题
  3. 理解timestamp
  4. LR11-更改licence
  5. 使你的 Google Summer of Code 建议被接收的5个技巧
  6. CSS图片去色
  7. Codeforces Round #316 (Div. 2)
  8. C语言对数组取地址
  9. django+nginx+uwsgi 部署配置
  10. DeepLearning.ai学习笔记(四)卷积神经网络 -- week4 特殊应用:人力脸识别和神经风格转换
  11. Reactor和Proactor
  12. layui 弹出框改变按钮颜色样式 自定义皮肤
  13. 【Java】模拟Sping,实现其IOC和AOP核心(一)
  14. 6-3 二叉树的重建 uva536
  15. 字符串和数组----string
  16. C#调用托管ocx、dll
  17. CSS中padding、margin、bordor属性详解
  18. SSIS 控制流和数据流
  19. php 扩展 debug问题
  20. mybatis的入门(一)

热门文章

  1. Java - 深拷贝技巧
  2. rabbit的fanout扇形交换机
  3. 远程连接Redis服务器
  4. 移动web中的幻灯片切换效果
  5. javascript闭包中循环问题
  6. Infor SyteLine如何快速锁定用户
  7. scrum心得和团队作业
  8. C++ *this与this的区别(系个人转载,个人再添加相关内容)
  9. idea配置maven后提示 commond not found
  10. 红黑树(R-B Tree)