批处理检查网络

Skiy 2008-7-20 855

::==================批处理检查网络==============
@echo off
setlocal enabledelayedexpansion
title 网络检查@bbs.bathome.cn
Rem '/*/////设置选项///////////////
set "Space= "
set "IP_cfg=%Space%IP Address"
set "GateWay=%Space%Default Gateway "
set "DNS=%Space%DNS Servers "
Rem '/*////////主程序//////////////
for /f "tokens=1,* delims=." %%i in ('ipconfig /all') do (
for %%a in (IP_cfg GateWay DNS) do (
if "%%i"=="!%%a!" (
Rem '/*-------将结果传回各变量名--------*/
set %%a=%%j
)
)
)
Rem '/*============对结果进行整理===============*/
echo 检查结果输出:
echo ======================
Rem '/*------处理IP------*/
set IP_cfg=%IP_cfg:*:=%
echo 检查网卡及其配置ing...
ping %IP_cfg% -n 2|find "Request timed out." && echo 网卡安装或配置有问题 ||echo 网卡正常:%
IP_cfg%
Rem '/*-----处理网关-----*/
echo.&echo 检查网关ing...
set GateWay=%GateWay:*:=%
ping %GateWay% -n 2|find "Request timed out." && echo 网关有问题 ||echo 网关正常:%GateWay%
Rem '/*-----处理DNS-----*/
echo.&echo 正在检查DNS...
set DNS=%DNS:*:=%
ping %DNS% -n 2|find "Request timed out." &&echo DNS有问题 ||echo DNS正常:%DNS%
pause>nul
最新回复 (0)
返回
发新帖