返回列表 发帖

50元有偿求个批处理设置IP、掩码、网关

WIN7环境,  比如原来的ip地址是192.168.1.11 掩码是255.255.255.0 网关是192.168.1.1
现在要求批处理自动修改ip 为192.168.1.11 掩码255.255.255.0 网关为空,  添加第2个ip  192.168.2.11 掩码255.255.255.0 网关192.168.2.1
N台机器, 所以思路应该就是  截取 ipconfig的 IPV4字符串, 然后只获取IP地址的最后一位 变量为 a
然后
netsh interface ipv4 set address name="本地连接 " addr=192.168.1.变量a mask=255.255.255.0 gwmetric=30
netsh interface ipv4 add address name="本地连接 " addr=192.168.2.变量a mask=255.255.255.0  gateway=192.168.2.1 gwmetric=1
微信18535804141

@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
pauseCOPY
1

评分人数

提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

已支付,请查收

TOP

返回列表