专门被call 调用- :ready
- for /F "tokens=1,2* delims=:. " %%a in ('ipconfig/all') do (
- if defined dns1 set dns2=%%a.%%b.%%c&goto:eof
- if /i "%%a %%b"=="Ethernet adapter" set NIC=%%c&call set NIC=%%NIC:~0,-2%%
- if /i "%%a %%b"=="IP Address" set "ip=%%c"
- if /i "%%a %%b"=="Default Gateway" set "gateway=%%c"
- if /i "%%a %%b"=="DNS Servers" set "dns1=%%c")
- goto:eof
复制代码 放到批处理的最后边
最后的goto:eof是防止ipconfig/all中没有dns1而设置的。如果本标签在批处理最后面的时候,可以不用这个goto:eof。但如果下面还有别的标签,推荐用。主要的返回,是依靠for内的goto:eof完成的
[ 本帖最后由 hanyeguxing 于 2010-4-18 22:55 编辑 ] |