修改 Gateway和DNS的vbs脚本
程序员文章站
2022-03-21 11:09:01
复制代码 代码如下:const t_gateway = "1.1.1.1" '网关 const t_newdns1 = "2.2.2.2" 'dns1 const t_ne...
复制代码 代码如下:
const t_gateway = "1.1.1.1" '网关
const t_newdns1 = "2.2.2.2" 'dns1
const t_newdns2 = "3.3.3.3" '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
无须重新启动,不管系统语言