本帖最后由 Samael 于 2021-10-26 17:04 编辑
试试可以正常获取不可以支持多网卡
[Asm] 纯文本查看 复制代码 @Echo OFF & Setlocal EnableDelayedExpansion
Echo. & Color 07
Set "str=defaultipgateway^,ipAddress^,DNSserversearchorder^,ipsubnet^,dhcpenabled^,MACAddress"
For /f "skip=1tokens=1*" %%i IN ('wmic nic where "manufacturer<>'microsoft' and netconnectionstatus='2'" get INdex^,netconnectionid^') DO (
For /f "tokens=1* Delims= " %%j IN ("%%j") DO (
Set $%%i=%%j
For /f "tokens=1-3Delims={}," %%a IN ('wmic nicconfig where "INdex='%%i'" get %str% /value') DO (
For /f %%c IN (%%c) DO IF /i "%%a" == "DNSserversearchorder=" Set "DNS2=%%c"
For /f %%c IN ("%%a%%~b") DO Set "%%c"
)
IF /i "!dhcpenabled!" == "true" (Echo.MAC:!MACAddress! 自动获取-网卡:%%j) Else (Echo.MAC:!MACAddress! 手动指定-网卡:%%j )
Echo. 地址 :!ipAddress!
Echo. 掩码 :!ipsubnet!
Echo. 网关 :!defaultipgateway!
Echo. 主DNS:!DNSserversearchorder!
Echo. 备DNS:!DNS2!
)
)
pause |