标题: [网络连接] [分享]批处理获取物理网卡的MAC地址(忽略虚拟网卡) [打印本页]
作者: Batcher 时间: 2023-5-25 22:32 标题: [分享]批处理获取物理网卡的MAC地址(忽略虚拟网卡)
【问题描述】
就比如我的电脑有两个vm虚拟网卡,一个真实物理网卡
怎么才能获取真实物理网卡的信息
作者: Batcher 时间: 2023-5-25 22:32
【解决方案】
test-1.bat- @echo off
- setlocal enabledelayedexpansion
- for /f "delims=:" %%i in ('ipconfig /all ^| findstr /n "以太网适配器" ^| findstr /v /i /c:"VMware" /c:"VirtualBox" /c:"蓝牙网络连接"') do (
- set /a SkipNum=%%i+3
- call :GetMAC !SkipNum!
- exit /b
- )
-
- :GetMAC
- for /f "skip=%1 tokens=2 delims=:" %%i in ('ipconfig /all') do (
- set "PhysicalMAC=%%i"
- set "PhysicalMAC=!PhysicalMAC: =!"
- goto :End
- )
-
- :End
- echo,!PhysicalMAC!
- pause
- exit /b
复制代码
作者: buyiyang 时间: 2023-5-25 23:44
本帖最后由 buyiyang 于 2023-5-25 23:49 编辑
wmic也可以- @echo off
- for /f "tokens=2 delims==" %%i in ('wmic nic where "PNPDeviceID like 'PCI\\%%'" get MACAddress /value') do echo,%%i
- for /f "tokens=2 delims==" %%i in ('wmic nic where "PNPDeviceID like '%%DEV%%'" get MACAddress /value') do echo,%%i
- pause
复制代码
作者: terse 时间: 2023-5-26 08:32
PS也方便复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |