首页 电脑 电脑学堂 查看内容

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

2009-8-5 12:30 901 0

摘要: 修改IP cmd /c netsh interface ip set address name=" 本地连接" source=static addr=211.82.56.253 mask=255.25...
关键词: NEWDNS 配置 gateway 网关 211.82 Const index setgateways strWinMgmt NIC

修改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
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部