当前位置: 移动技术网 > IT编程>脚本编程>VBScript > CMD和vbs修改 IP地址及DNS的实现代码

CMD和vbs修改 IP地址及DNS的实现代码

2017年12月08日  | 移动技术网IT编程  | 我要评论

达生集团,太原工业学院教务处,家长网

修改ip

cmd /c netsh interface ip set address name=" 本地连接" source=static addr=211.82.56.253 mask=255.255.255.0 gateway=211.82.56.1 gwmetric=1

修改dns
cmd /c netsh interface ip set dns name="本地连接" source=static addr=202.99.192.66


配置或更新ip地址:
wmic nicconfig where index=0 call enablestatic("192.168.1.5"), ("255.255.255.0") ;index=0说明是配置网络接口1。


配置网关(默认路由):
wmic nicconfig where index=0 call setgateways("192.168.1.1"),(1)


vbs

const t_gateway = "211.82.56.1" '网关
const t_newdns1 = "202.99.192.66" 'dns1
const t_newdns2 = "60.221.248.43" 'dns2
strwinmgmt="winmgmts:{impersonationlevel=impersonate}"
set nics = getobject( strwinmgmt ).instancesof("win32_networkadapterconfiguration")
for each nic in nics
if nic.ipenabled then
nic.setdnsserversearchorder array(t_newdns1,t_newdns2)
nic.setgateways array(t_gateway)
end if
next

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网