参照
http://bbs.bathome.net/thread-32288-1-1.html
写了获取多网卡系统中指定网络连接对应的IP地址- @echo off
- REM 设置网络适配器的名称
- REM 英文系统一般是:Local Area Connection
- REM set "AdapterName=Local Area Connection"
- REM 中文系统一般是:本地连接
- set "AdapterName=本地连接"
- set "WireName=无线网络连接"
- set "FileTmp=%temp%\ipList.txt"
- ipconfig /all >"%FileTmp%"
- for /f "delims=:" %%i in ('findstr /n /c:"%AdapterName%" "%FileTmp%"') do (
- set "SkipRow=%%i"
- goto :DoSkip
- )
-
- :DoSkip
- for /f "tokens=2 delims=:(" %%i in ('more +%SkipRow% "%FileTmp%" ^| findstr /v "IPv6" ^|findstr "IP"') do (
- set "IP=%%i"
- goto :ShowResult
- )
-
- :ShowResult
- for /f "delims=:" %%i in ('findstr /n /c:"%WireName%" "%FileTmp%"') do (
- set "SkipRow1=%%i"
- goto :1
- )
-
- :1
- for /f "tokens=2 delims=:(" %%i in ('more +%SkipRow1% "%FileTmp%" ^| findstr /v "IPv6" ^|findstr "IP"') do (
- set "WIP=%%i"
- goto :2
- )
-
- :2
- echo,%IP%
- echo,%WIP%
- pause
复制代码 问题来了,如果无线未连接时,无线IP也会显示,与有线IP相同,这要怎么处理,或是用别的代码 |