闲着没事做,就写个排除网络故障的批处理来,供大家使用,呵呵,从来没写过这么长的批处理,参看了些资料,才把它给写出来,还用了一个上午的时间,呵呵,而且是用的是上班的时间,哈哈。好了不说那么多废话!将以下代码复制到记事本保存为 nettest.bat 运行下试试吧、自我感觉很不错的哦。

@echo on
color 0a
MODE con: COLS=80 LINES=20 
::设置CMD窗口的大小的作用
title 网络故障排除P处理——罗斌制作——QQ:287727615
echo 如果您是DHCP动态或得IP地址的请选择1,如果是手动配置IP地址的请选择2.
@echo off 
::以下是设置该批处理的选择菜单
:menu
echo.
echo                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo                  请选择要进行的操作,然后按回车
echo                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo.
echo                  1.DHCP动态获得IP地址
echo.
echo                  2.检查查网络连通性,排除网络故障
echo.
echo                  3.退出
:cho
set /p choice= 请选择:
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="1" goto a
if /i "%choice%"=="2" goto b
if /i "%choice%"=="3" goto end
echo 选择无效,请重新输入
echo.
goto cho
::选择菜单的结束,也就是说能让批处理做得模块化!
:a
ipconfig /release
ipconfig /renew
echo 您现在是手动配置的TCP/IP。
goto menu
@echo off
:b
::下面这些我就不多说了。先PING 将结果存到1.txt里面,然后通过type 1.txt | find "Destination host unreachable." 查找里面的代码
然后判断的结果!
set /p IP=请输入您内网某台在线主机的IP:
ping %IP% >1.txt
type 1.txt | find "Destination host unreachable. Request timed out." && echo "错误:请检查您是否禁用了TCP/IP,是否正确配置
TCP/IP属性以及您连在的网线是否已经连接正常."
type 1.txt | find "Destination host unreachable." && echo "错误:请检查您是否禁用了TCP/IP,是否正确配置TCP/IP属性以及您连在的
网线是否已经连接正常." && del 1.txt
type 1.txt | find " Sent = 4, Received = 4, Lost = 0" && echo "能ping通内网%IP%这台电脑,说明您的内网正常!" && del 1.txt
set /p IP=请输入网关IP:
ping %IP% >1.txt
set filename=1.txt
type %filename% |find "bytes=" && echo "恭喜您,您的网络一切正常!"
for %%i in (unreachable)  do type %filename% |find "%%i"  && echo "错误:请检查您是否禁用了TCP/IP,以及您连在的网线是否已经连
接正常." 
::type %filename% |find "check"  && echo "错误:请检查您是否正确配置网关以及您连在网关设备上的网线是否连接上."

type 1.txt | find " Sent = 4, Received = 4, Lost = 0" && echo "能ping通网关%IP%,您的机器到网关之间的连接没有任何问题!" &&
del 1.txt
echo 正在ping百度....
ping  www.baidu.com >1.txt
type 1.txt | find "Request timed out." && echo "错误:不能ping通 www.baidu.com,说明您的DNS配置有误,或者您的NDS服务器DOWN机(
一般是路由器的问题,重启下路由器就OK 啦。)。请查明原因...为了测试的准确性请您多测试几次!!!" && del 1.txt
type 1.txt | find "Please check the name and try again." && echo "错误:不能ping通 www.baidu.com,说明您的DNS配置有误,或者您的
NDS服务器DOWN机(一般是路由器的问题,重启路由器就OK 啦。如果还不行则试下ARP -S命令绑定下MAC地址试试。)。请查明原因..为了测试
的准确性请您多测试几次!!!" && del 1.txt
type 1.txt | find " Sent = 4, Received = 4, Lost = 0" && echo "能ping通[www.baidu.com]表示您可以正常上Internet!" && del
1.txt && echo 恭喜您!!!您的网络非常正常!!!如果有其他什么问题请Q我:287727615
pause & exit
转载文章请标明:该文章转自 罗斌原创技术文章:http://luobin44.51.com 〖罗斌原创〗