@echo off
set MinL=99
set MinT=9999ms
set Best=""
for /f "usebackq" %%a in ("QQlist.txt") do (
call :time %%a
)
echo 最佳服务器:%Best%
echo 最佳服务器的响应时间:%MinT%
goto :eof
:time
for /f "skip=11 tokens=4 delims==" %%a in ('ping %1') do (
if "%%a" equ " 0ms" (
set /a Best=%1
) else (
call :best %%a %1
)
goto :eof
)
:best
for /f "skip=1 delims=:" %%a in ('^(echo %1^&echo.^)^|findstr /o ".*"') do set nowlen=%%a
if "%nowlen%" lss "%MinL%" (
set /a MinL=%nowlen%
set MinT=%1
set Best=%2
) else if "%nowlen%" equ "%MinL%" (
if "%1" lss "%MinT%" (
set MinT=%1
set Best=%2
)
)
goto :eof
我又做了点修改!!不过比较笨,还想麻烦给改一改!!!不甚感激
@echo off
ping sz.tencent.com > QQsev.txt
ping sz1.tencent.com >> QQsev.txt
ping sz2.tencent.com >> QQsev.txt
ping sz3.tencent.com >> QQsev.txt
ping sz4.tencent.com >> QQsev.txt
ping sz5.tencent.com >> QQsev.txt
ping sz6.tencent.com >> QQsev.txt
ping sz7.tencent.com >> QQsev.txt
type QQsev.txt | find "Pinging" >temp.txt
cd. >QQlist.txt
for /f "tokens=3 delims= " %%a in (temp.txt) do (echo %%a >>QQlist.txt)
set MinL=99
set MinT=9999ms
set Best=""
for /f "usebackq" %%a in ("QQlist.txt") do (
call :time %%a
)
echo 最佳服务器:%Best% >result.txt
echo 最佳服务器的响应时间:%MinT% >>result.txt
call result.txt
goto :eof
:time
for /f "skip=11 tokens=4 delims==" %%a in ('ping %1') do (
if "%%a" equ " 0ms" (
set /a Best=%1
) else (
call :best %%a %1
)
goto :eof
)
:best
for /f "skip=1 delims=:" %%a in ('^(echo %1^&echo.^)^|findstr /o ".*"') do set
nowlen=%%a
if "%nowlen%" lss "%MinL%" (
set /a MinL=%nowlen%
set MinT=%1
set Best=%2
) else if "%nowlen%" equ "%MinL%" (
if "%1" lss "%MinT%" (
set MinT=%1
set Best=%2
)
)
goto :eof
[ Last edited by youling126 on 2008-5-15 at 07:01 PM ]
@echo off
echo sz.tencent.com>"QQlist.txt"
echo sz1.tencent.com>>"QQlist.txt"
echo sz2.tencent.com>>"QQlist.txt"
echo sz3.tencent.com>>"QQlist.txt"
echo sz4.tencent.com>>"QQlist.txt"
echo sz5.tencent.com>>"QQlist.txt"
echo sz6.tencent.com>>"QQlist.txt"
echo sz7.tencent.com>>"QQlist.txt"
set MinL=99
set MinT=9999ms
set Best=""
for /f "usebackq" %%a in ("QQlist.txt") do (
call :time %%a
)
echo 最佳服务器:%Best%
echo 最佳服务器的响应时间:%MinT%
goto :eof
:time
for /f "skip=11 tokens=4 delims==" %%a in ('ping %1') do (
if "%%a" equ " 0ms" (
set /a Best=%1
) else (
call :best %%a %1
)
goto :eof
)
:best
for /f "skip=1 delims=:" %%a in ('^(echo %1^&echo.^)^|findstr /o ".*"') do set nowlen=%%a
if "%nowlen%" lss "%MinL%" (
set /a MinL=%nowlen%
set MinT=%1
set Best=%2
) else if "%nowlen%" equ "%MinL%" (
if "%1" lss "%MinT%" (
set MinT=%1
set Best=%2
)
)
goto :eof
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
for /f "delims=" %%i in (ip.txt) do (
set st=
(ping -n 1 %%i>nul)&&(set st=%%i)||(echo 999ms %%i>>temp1)
if defined st for /f "tokens=7 delims== " %%t in ('ping -n 1 %%i^|find /i "Reply from"') do echo %%t %%i>>temp1
)
for /f "tokens=1,2" %%a in (temp1) do (
set t=%%a
if "!t:~4,1!"=="" set "t= !t!"
echo !t! %%b>>temp2
)
for /f "tokens=1,2" %%a in ('sort temp2') do (echo %%a %%b>result.txt&del temp1 temp2&start result.txt&exit /b)
@echo off
for /f "delims=" %%a in ('more +11 "%~0"') do for /f "skip=11 tokens=4 delims==" %%i in ('ping %%a') do (
set str=%%i
call set str=00000%%str: =%%
call set str=%%str:~-5%%
call set -%%str%%=%%a
)
for /f "tokens=1,2 delims=0-=" %%i in ('set -') do echo %%j %%i&goto end
:end
pause
exit
sz.tencent.com
sz1.tencent.com
sz2.tencent.com
sz3.tencent.com
sz4.tencent.com
sz5.tencent.com
sz6.tencent.com
sz7.tencent.com
@echo off
for /f "skip=3 tokens=1-3" %%a in ('ping -n 1 -l 1 sz.tencent.com') do echo %%c >"QQlist.txt"
for /f "skip=3 tokens=1-3" %%a in ('ping -n 1 -l 1 sz1.tencent.com') do echo %%c >>"QQlist.txt"
for /f "skip=3 tokens=1-3" %%a in ('ping -n 1 -l 1 sz2.tencent.com') do echo %%c >>"QQlist.txt"
for /f "skip=3 tokens=1-3" %%a in ('ping -n 1 -l 1 sz3.tencent.com') do echo %%c >>"QQlist.txt"
for /f "skip=3 tokens=1-3" %%a in ('ping -n 1 -l 1 sz4.tencent.com') do echo %%c >>"QQlist.txt"
for /f "skip=3 tokens=1-3" %%a in ('ping -n 1 -l 1 sz5.tencent.com') do echo %%c >>"QQlist.txt"
for /f "skip=3 tokens=1-3" %%a in ('ping -n 1 -l 1 sz6.tencent.com') do echo %%c >>"QQlist.txt"
for /f "skip=3 tokens=1-3" %%a in ('ping -n 1 -l 1 sz7.tencent.com') do echo %%c >>"QQlist.txt"
set MinL=99
set MinT=9999ms
set Best=""
for /f "usebackq" %%a in ("QQlist.txt") do (
call :time %%a
)
echo 最佳服务器:%Best%
echo 最佳服务器的响应时间:%MinT%
goto :eof
:time
for /f "skip=11 tokens=4 delims==" %%a in ('ping %1') do (
if "%%a" equ " 0ms" (
set /a Best=%1
) else (
call :best %%a %1
)
goto :eof
)
:best
for /f "skip=1 delims=:" %%a in ('^(echo %1^&echo.^)^|findstr /o ".*"') do set nowlen=%%a
if "%nowlen%" lss "%MinL%" (
set /a MinL=%nowlen%
set MinT=%1
set Best=%2
) else if "%nowlen%" equ "%MinL%" (
if "%1" lss "%MinT%" (
set MinT=%1
set Best=%2
)
)
goto :eof
@echo off&setlocal enabledelayedexpansion
echo 请稍候......
for /f "delims=" %%a in ('more +16 "%~0"') do (
set tx=%%a&set var=
for /f "tokens=1-4 delims==" %%i in ('ping %%a^|findstr /i "%%a Average"') do call:LP "%%j" "%%l")
for /f "tokens=1,2 delims=-=0" %%i in ('set -') do echo 最快服务器:%%j IP地址:!%%j! 响应时间%%i&goto end
:end
pause&exit
:LP
if not defined var set var=%~1
if not %2=="" (
set str=%~2&set str=!str: =!
set str=00000000!str!&set str=!str:~-10!
set -!str!=%TX%&set %TX%=!var!
)
goto :eof
sz.tencent.com
sz1.tencent.com
sz2.tencent.com
sz3.tencent.com
sz4.tencent.com
sz5.tencent.com
sz6.tencent.com
sz7.tencent.com