
如何獲取指定網(wǎng)絡(luò)連接對應(yīng)的IP地址參照http://bbs.bathome.net/thread-32288-1-1.html寫了獲取多網(wǎng)卡系統(tǒng)中指定網(wǎng)絡(luò)連接對應(yīng)的IP地址
問題來了,如果無線未連接時,無線IP也會顯示,與有線IP相同,這要怎么處理,或是用別的代碼nclick="copycode($('code0'));">復(fù)制代碼
- @echo off
- REM 設(shè)置網(wǎng)絡(luò)適配器的名稱
- REM 英文系統(tǒng)一般是:Local Area Connection
- REM set AdapterName=Local Area Connection
- REM 中文系統(tǒng)一般是:本地連接
- set AdapterName=本地連接
- set WireName=無線網(wǎng)絡(luò)連接
- 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

