脚本宝典收集整理的这篇文章主要介绍了CMD和vbs修改 IP地址及DNS的实现代码,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
修改IP cmd /c netsh interface ip set address n
ame=" 本地连接" 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 nic
config 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:{im
PErsonationLevel=impersonate}"
Set NICS = GetObject( strWinMgmt ).InstancesOf("Win32_NetworkAdapterConfiguration")
For
each NIC In NICS
If NIC.IPEnabled Then
NIC.SetDNSServerSe
ArchOrder Array(T_NEWDNS1,T_NEWDNS2)
NIC.SetGateways Array(T_GATEWAY)
End If
Next
脚本宝典总结
以上是脚本宝典为你收集整理的CMD和vbs修改 IP地址及DNS的实现代码全部内容,希望文章能够帮你解决CMD和vbs修改 IP地址及DNS的实现代码所遇到的问题。
如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。