例如要将所有计算机的DNS更改为:192.168.1.2,192.168.1.3,192.168.2.2,192.168.1.2.3,可以通过域计算机策略开机脚本统一部署以下脚本。

On Error Resume Next
temp=0
set wshshell=wscript.createobject("wscript.shell")
'启动WMI服务
'wshshell.run ("%comspec% /c regsvr32 /s scrrun.dll"),0,True
'wshshell.run ("%comspec% /c sc config   winmgmt start= auto"),0,True
'wshshell.run ("%comspec% /c net start winmgmt"),0
'wshshell.run ("%comspec% /c sc config   NetMan start= auto"),0,True
'wshshell.run ("%comspec% /c net start NetMan"),0

strComputer = "."
Set objWMIService = getobject("winmgmts:\" & strComputer & "\root\cimv2")

'得到当前活动网卡ID
Set colItems = objWMIService.ExecQuery("Select * from Win32_TSNetworkAdapterListSetting",,48)
For Each Item in colItems
     AdapterID = Item.NetworkAdapterID
Next

'更改DNS
Set reg = WScript.CreateObject("WScript.Shell")
reg.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces"&AdapterID&"\NameServer","192.168.1.2,192.168.1.3,192.168.2.2,192.168.1.2.3,"REG_SZ"