
CODE: [Copy to clipboard][ Last edited by HAT on 2008-11-9 at 22:12 ]@echo off
ping [url]www.yahoo.com.cn[/url] >%temp%\1.txt
find "Ping statistics for" %temp%\1.txt >%temp%\2.txt
for /f "skip=2 tokens=4" %%M in (%temp%\2.txt) do set IP_=%%M
del %temp%\1.txt
del %temp%\2.txt
:: 去掉那个%IP_%最后那个冒号
setlocal ENABLEDELAYEDEXPANSION
for /f "delims=" %%i in ("%IP_%") do (
set ip=%%i
set "ip=!ip::=!"
)
setlocal DISABLEDELAYEDEXPANSION
echo %ip%
pause
CODE: [Copy to clipboard]如果网速较慢,适当调整/w后面的等待时间@echo off
for /f "tokens=2 delims=[]" %%i in ('ping www.yahoo.com.cn /n 1 /w 0') do echo %%i
pause
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) | Powered by Discuz! 2.5 |