批处理获取IP地址

 

setlocal ENABLEEXTENSIONS & set "i=0.0.0.0" & set "j="
for /f "tokens=4" %%a in ('route print^|findstr 0.0.0.0.*0.0.0.0') do (
  if not defined j for %%b in (%%a) do set "i=%%b" & set "j=1")
endlocal & set "ip=%i%"
echo IP 地址是:%ip%
pause

 

posted on 2014-05-08 22:19  harrell  阅读(2200)  评论(0编辑  收藏  举报