From 74665b65cca8620f3ecfdbf77b62bb819f0771b3 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Tue, 7 Oct 2025 02:58:20 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"dd:=20=E4=BF=AE=E5=A4=8D=E9=95=9C?= =?UTF-8?q?=E5=83=8F=E6=B2=A1=E6=9C=89=20wmic=20=E6=97=B6=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E9=85=8D=E7=BD=AE=E9=9D=99=E6=80=81=20IP"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 6708c77c6389aabb8267714ff5aed403bed5192d. --- windows-set-netconf.bat | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/windows-set-netconf.bat b/windows-set-netconf.bat index 07fe54d..c4d5fff 100644 --- a/windows-set-netconf.bat +++ b/windows-set-netconf.bat @@ -19,23 +19,7 @@ netsh interface ipv6 set global randomizeidentifiers=disabled rem 检查是否定义了 MAC 地址 if defined mac_addr ( - rem vista 没有自带 powershell - rem win11 24h2 安装后有 wmic,但是过一段时间会自动删除,因此有的 dd 镜像没有 wmic - if exist "%windir%\system32\wbem\wmic.exe" ( - for /f "tokens=2 delims==" %%a in ( - 'wmic nic where "MACAddress='%mac_addr%'" get InterfaceIndex /format:list ^| findstr /r "^InterfaceIndex=[0-9][0-9]*$"' - ) do set id=%%a - ) - if not defined id ( - for /f %%a in ('powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass ^ - -Command "(Get-WmiObject Win32_NetworkAdapter | Where-Object { $_.MACAddress -eq '%mac_addr%' }).InterfaceIndex" ^| findstr /r "^[0-9][0-9]*$"' - ) do set id=%%a - ) - if not defined id ( - for /f %%a in ('powershell -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass ^ - -Command "(Get-CimInstance Win32_NetworkAdapter | Where-Object { $_.MACAddress -eq '%mac_addr%' }).InterfaceIndex" ^| findstr /r "^[0-9][0-9]*$"' - ) do set id=%%a - ) + for /f %%a in ('wmic nic where "MACAddress='%mac_addr%'" get InterfaceIndex ^| findstr [0-9]') do set id=%%a if defined id ( rem 配置静态 IPv4 地址和网关 if defined ipv4_addr if defined ipv4_gateway (