windows 经过域策略开机脚本批量改服务器dns

更改DNS脚本shell

例如要将全部计算机的DNS更改成:192.168.1.2,192.168.1.3能够经过域计算机策略开机脚本统一部署如下脚本。ide

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"),0ip

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

'获得当前活动网卡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\Interfacesget

\"&AdapterID&"\NameServer","192.168.1.2,192.168.1.3"REG_SZ"it

相关文章
相关标签/搜索