想弄一个最快的服务器,然后获取最快的服务器IP地址,结果这个代码在XP下可用,win7下面就出错,不能查找到最快的服务器,想请各位帮忙看看,谢谢!
代码如下:- @echo off
- mode con COLS=37 lines=5
- color 0a
- cls
- net config workstation |(find /i "windows 7")&&(goto windows7)
- ver |(find /i "windows XP")&&(goto xp)||(goto notxpandwindows7)
- exit
-
- :xp
- echo 正在搜索最快的服务器...
- echo.
- echo 30秒后打开网页,请稍后...
- echo.
- setlocal enabledelayedexpansion
- set f=9999
- for %%i in (www.baidu.com www.qq.com www.sina.com.cn) do (
- for /f "tokens=4 delims==" %%j in ('ping -n 3 %%i^|findstr Average') do (
- set s=%%j
- set /a s=!s:ms=!
- if !s! lss !f! set f=!s!&set ff=%%i))
- echo 最快的服务器是!ff! !f!ms
- for /f "tokens=2 delims=[]" %%a in ('ping !ff!^|findstr "Ping"') do (
- set IP=%%a
- )
- echo,%IP%
- pause
- exit
-
- :windows7
- echo 这段代码错误
- echo 正在搜索最快的服务器...
- echo.
- echo 30秒后打开网页,请稍后...
- echo.
- setlocal enabledelayedexpansion
- set f=9999
- for %%i in (www.baidu.com www.qq.com www.sina.com.cn) do (
- for /f "tokens=4 delims==" %%j in ('ping -n 3 %%i^|findstr /i "平均 Average"'') do (
- set s=%%j
- set /a s=!s:ms=!
- if !s! lss !f! set f=!s!&set ff=%%i))
- echo 最快的服务器是!ff! !f!ms
- for /f "tokens=2 delims=[]" %%a in ('ping !ff!^|findstr "Ping"') do (
- set IP=%%a
- )
- echo,%IP%
- pause
- exit
-
- :notxpandwindows7
- echo.
- echo.
- echo 您的系统不是xp和win7
- echo 5秒后退出
- ping /n 5 127.0.0.1>nul
- exit
复制代码
|