标题: 50元有偿求个批处理设置IP、掩码、网关 [打印本页]
作者: kurosaki 时间: 2018-11-23 10:15 标题: 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
作者: zaqmlp 时间: 2018-11-23 11:57
- @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
复制代码
作者: kurosaki 时间: 2018-11-23 12:08
已支付,请查收
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |