以下是使用批处理脚本获取MAC地址和网络适配器名称,并将其物理地址设置为变量并显示出来的示例代码:

@echo off
setlocal enabledelayedexpansion

REM 获取网络适配器信息
for /f "tokens=2 delims=: " %%a in ('ipconfig /all ^| find "Physical Address"') do (
    set "adapter=%%a"
    set "adapter=!adapter: =!"
    echo 网络适配器: !adapter!
)

REM 获取MAC地址并设置为变量
for /f "tokens=2 delims=: " %%a in ('ipconfig /all ^| find "Physical Address"') do (
    set "mac=%%a"
    set "mac=!mac: =!"
    echo MAC地址: !mac!
)

endlocal

运行这个批处理脚本,它将输出每个网络适配器的名称和对应的MAC地址。

批处理获取MAC地址和网络适配器名称

原文地址: https://www.cveoy.top/t/topic/pgzA 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录