[群友分享] 批处理修改IP地址的办法

  2018年11月23日  深蓝  6681 阅读 Tag:

感谢深蓝软件群友 G K 为大家分享。

实现的功能为:

QQ截图20181123131653.png

 

批处理为:

@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
exit

 


      我的工单留言列表与站长回复 . 共有留言: 81 条