标题: [网络工具] 批处理获取多网卡系统中指定网络连接对应的MAC地址 [打印本页]
作者: Batcher 时间: 2014-9-30 17:42 标题: 批处理获取多网卡系统中指定网络连接对应的MAC地址
- @echo off
- REM 设置网络适配器的名称
- REM 英文系统一般是:Local Area Connection
- REM set "AdapterName=Local Area Connection"
- REM 中文系统一般是:本地连接
- set "AdapterName=本地连接"
-
- 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 "..-..-..-..-..-.."') do (
- set "MAC=%%i"
- goto :ShowResult
- )
-
- :ShowResult
- set "MAC=%MAC: =%"
- echo,%MAC%
- pause
复制代码
作者: Linuxer 时间: 2014-9-30 18:19
学习下代码思路,。多谢大神~~还是沙发。。哦
作者: Rocmind 时间: 2014-12-18 20:24
很好的工具,实用有效
作者: Batcher 时间: 2022-10-19 14:41
批处理获取多网卡系统中指定网络连接对应的MAC地址和IP地址- @echo off
- REM 设置网络适配器的名称
- set "AdapterName=以太网 2"
-
- set "FileTmp=%temp%\ipList.txt"
- ipconfig /all >"%FileTmp%"
- for /f "delims=:" %%i in ('findstr /n /c:"%AdapterName%" "%FileTmp%"') do (
- set "SkipRow=%%i"
- goto :FindMAC
- )
-
- :FindMAC
- for /f "tokens=2 delims=:" %%i in ('more +%SkipRow% "%FileTmp%" ^| findstr "..-..-..-..-..-.."') do (
- set "MAC=%%i"
- goto :FindIP
- )
-
- :FindIP
- for /f "tokens=2 delims=:(" %%i in ('more +%SkipRow% "%FileTmp%" ^| findstr /v "IPv6" ^| findstr "IP"') do (
- set "IP=%%i"
- goto :ShowResult
- )
-
- :ShowResult
- set "MAC=%MAC: =%"
- echo,%MAC%
- set "IP=%IP: =%"
- echo,%IP%
- pause
复制代码
作者: wxf617 时间: 2022-10-29 16:07
很实用的东西,谢谢楼主
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |