更改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