@echo off
setlocal enabledelayedexpansion
chcp 65001 >nul
cls
echo ==================== 主活跃网卡 MAC地址 ====================
echo.

set "flag=0"
:: wmic 输出顺序：MACAddress 在前，Name 在后，调换显示位置
for /f "skip=1 tokens=1,2" %%a in ('wmic nic where "NetEnabled=TRUE and NetConnectionStatus=2" get Name^,MACAddress /format:table 2^>nul') do (
    if !flag! equ 0 (
        if not "%%a"=="" (
            echo 网卡名称：%%b
            echo MAC 地址：%%a
            set "flag=1"
        )
    )
)

if !flag! equ 0 (
    echo 未检测到已连接的网卡
)

echo.
echo ==============================================================
pause >nul