标题: dos批处理改IP
[打印本页]
作者: magiciankcat
时间: 2009-11-9 17:52
标题: dos批处理改IP
@ echo off
rem 设置变量
set Nic=本地连接
rem //可以根据你的需要更改,
set Addr=192.168.1.162
set Mask=255.255.255.0
set Gway=192.168.1.1
set Dns1=221.4.66.66
set Dns2=221.4.8.1
rem //以上依次为IP地址、子网掩码、网关、首选DNS、备用DNS
echo ------------------------------------------------------
echo 正在进行IP设置,请稍等
rem //可以根据你的需要更改
echo. IP地址 = %Addr%
echo. 子网掩码 = %Mask%
netsh interface ip set address name=%Nic% source=static addr=shy;dr% mask=%Mask% >nul
echo. 网关 = %Gway%
netsh interface ip set address name=%Nic% gateway=%Gway% gwmetric=1 >nul
echo. 首选DNS = %Dns1%
netsh interface ip set dns name=%Nic% source=static addr=%Dns1% register=PRIMARY >nul
echo. 备用DNS = %Dns2%
netsh interface ip add dns name=%Nic% addr=%Dns2% index=2 >nul
echo ------------------------------------------------------
echo IP设置完成!
netsh interface ip add dns name=%Nic% addr=%Dns3% index=2 >nul
rem pause >nul
上网找的
可是改了之后不知道为什么不能用
就是改不了
=、=先谢谢了
很急
明天需要
[
Last edited by magiciankcat on 2009-11-9 at 17:54 ]
作者: ccyyxxx
时间: 2009-11-9 19:19
netsh interface ip set address name=%Nic% source=static addr=shy;dr% mask=%Mask% >nul
这句应该为,不然报错
netsh interface ip set address name="%Nic%" source=static addr=%Addr% mask=%Mask% >nul
[
Last edited by ccyyxxx on 2009-11-9 at 19:23 ]
作者: ccyyxxx
时间: 2009-11-9 19:23
netsh interface ip set address name="%Nic%" source=static addr=%Addr% mask=%Mask% gateway=%Gway% >NUL
netsh interface ip set dns name="%Nic%" source=static addr=%Dns1% >NUL
netsh interface ip add dns "%Nic%" addr=%Dns2% >NUL
作者: magiciankcat
时间: 2009-11-10 12:21
谢谢上面的提醒
很多都没有冒号
甚至打错了变量名字
谢谢了=、=