想从域名查得对应ip,以下代码不知能否通用?能否用更简洁的方式?新手学习中,请多多指点
@echo off
ping www.yahoo.com.cn >%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
Last edited by HAT on 2008-11-9 at 22:12 ]