我想写一批处理,获取电脑里“本地连接”所在网卡的MAC地址,也就是获取“Ethernet adapter 本地连接:”行下第四行“Physical Address”的值。需要注意的是不同的机子上可能网卡不止一个。比如我这个机子:ipconfig /all 如下:
Windows IP Configuration
Host Name . . . . . . . . . . . . : IBM_T60_HGX
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : Yes
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter 无线网络连接:
Media State . . . . . . . . . . . : Media disconnected
Description . . . . . . . . . . . : Intel(R) PRO/Wireless 3945ABG Network Connection
Physical Address. . . . . . . . . : 00-13-02-A3-F9-18
Ethernet adapter 本地连接:
Media State . . . . . . . . . . . : Media disconnected
Description . . . . . . . . . . . : Intel(R) PRO/1000 PL Network Connection
Physical Address. . . . . . . . . : 02-80-41-59-C7-2C
Ethernet adapter 本地连接 2:
Media State . . . . . . . . . . . : Media disconnected
Description . . . . . . . . . . . : VPN Virtual Network Adapter
Physical Address. . . . . . . . . : 00-00-00-14-35-22
用以下批处理得到是最后一个网卡的MAC,。
for /f "tokens=2 delims=:" %%l in ('ipconfig /all ^| find /i "Physical Address"') do set mac=%%l
echo 本机MAC地址为:%mac%
pause
求大家帮忙,如何能得到“本地连接”网卡的MAC。