Windows批处理:自动检查网络连通性
2015-07-30 17:47
766 查看
检测网络连通性我用的是丛远到近的方法,即“外网——网关——内网——本机”,脚本的实现也是根据这个顺序用ping来检测,为提高检测速度,这里我只ping了2次,各位可以根据自己的需要进行修改。 使用方法大神们都会的... 复制代码,另存为.bat文件后执行。
效果如下:
@echo off color 2F title 网络连通性检测 echo. echo. ping -n 2 223.5.5.5>%temp%\1.ping & ping -n 2 223.6.6.6>>%temp%\1.ping ::ping阿里公共DNS findstr "TTL" %temp%\1.ping>nul if %errorlevel%==0 (echo √ 外网正常) else (echo × 外网不通) ::根据返回值输出 echo. ping -n 2 192.168.1.1>%temp%\2.ping findstr "TTL" %temp%\2.ping>nul if %errorlevel%==0 (echo √ 网关正常) else (echo × 网关不通) echo. ping -n 2 192.168.1.2>%temp%\3.ping findstr "TTL" %temp%\3.ping>nul if %errorlevel%==0 (echo √ 内网正常) else (echo × 内网不通) echo. ping -n 2 127.0.0.1>%temp%\4.ping findstr "TTL" %temp%\4.ping>nul if %errorlevel%==0 (echo √ TCP/IP协议正常) else (echo × TCP/IP协议异常) if exist %temp%\*.ping del %temp%\*.ping ::删除缓存文件 echo. echo. pause
效果如下:
相关文章推荐
- android wifi 无线调试
- 运维入门
- 动态清空 nohup 输出文件
- install scrapy with pip and easy_install
- 5 个用于在 Linux 终端中查找域名 IP 地址的命令
- Linux Shell常用技巧
- 如何让 Ping 的输出更简单易读
- VBS脚本写的Windows硬件检测工具分享
- 用vbscript实现隐藏任务栏图标的脚本
- 用autoit编写第一个脚本(Hello World)
- VBS调用WMI快速关闭IE的脚本
- 收集的ROS防火墙脚本
- JSP脚本漏洞面面观
- shell字符串操作详解
- 不错的批处理脚本 第一部分
- VBS脚本加密/解密VBS脚本(简易免杀版1.1)
- 不错的批处理脚本实例代码 第二部分
- 使用脚本和批处理清除电脑中的痕迹的代码第1/2页
- 让你的脚本说话