- @echo off
- for /f "delims=" %%a in ('wmic NIC where "NetEnabled='TRUE'" get MACAddress^,NetConnectionID /value^|find "="') do set %%a
- for /f "delims=" %%a in ('wmic NICCONFIG where "MACAddress='%MACAddress%'" get IPAddress /value^|find "="') do set %%a
- for /f "delims={," %%a in ("%IPAddress%") do set ip=%%~a
- for /f "tokens=1-4 delims=." %%a in ("%ip%") do set last=%%d
- echo;%ip%
- echo;%last%
- echo;%NetConnectionID%
-
- netsh interface ipv4 set address name="本地连接" addr=192.168.1.%last% mask=255.255.255.0 gwmetric=30
- netsh interface ipv4 add address name="本地连接" addr=192.168.2.%last% mask=255.255.255.0 gateway=192.168.2.1 gwmetric=1
- pause
复制代码
|