假设含有DEV_4727的是加插网卡,另一个是板载网卡- @echo off
- wmic exit || exit /b 1
- for /f "delims=" %%a in ('
- wmic nic where "NetConnectionID > ''" get NetConnectionID^,PNPDeviceID /value
- ') do for /f "delims=" %%i in ("%%a") do (
- rem 这里多加了一个for是为了过滤wmic输出中的多余回车符
- set "%%i"
- set "#=%%i"
- setlocal enableDelayedExpansion
- if /i "!#:~,11!" == "PNPDeviceID" (
- if "!PNPDeviceID:DEV_4727=!" neq "!PNPDeviceID!" (
- echo 加插网卡: "!NetConnectionID!"
- echo netsh int ip set addr "!NetConnectionID!" static 192.168.1.X 255.255.255.0
- ) else if /i "!PNPDeviceID:~,3!" == "PCI" (
- echo 板载网卡: "!NetConnectionID!"
- echo netsh int ip set addr "!NetConnectionID!" static 172.23.1.X 255.255.0.0
- )
- )
- endlocal
- )
- pause
复制代码
|