Sets the following DNS related settings on the network adapters:
'SetTCPIPDNSSettings.vbs 'For modifying the DNS related settings on the network adapters. '20100507, v1 '20120115, v2 ' Added DNSSuffixSearchDomains. On Error Resume next strComputer = "." 'Array of DNS servers to use. arrDNSServers = Array("10.1.1.1","10.1.1.2") 'Comma seperated no spaces string of domains to search if only given a hostname. strDNSSuffixSearchDomains = "sub.domain.com,domain.com,ad.internal" strDNSDomain = "sub.domain.com" bFullDNSRegistrationEnabled = True bDomainDNSRegistrationEnabled = True Set objShell = CreateObject("WScript.Shell") Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 'http://msdn.microsoft.com/en-us/library/aa394217(VS.85).aspx - Win32_NetworkAdapterConfiguration Class. Set colIPConfig = objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE") For Each IPConfig in colIPConfig IPConfig.SetDNSServerSearchOrder(arrDNSServers) IPConfig.SetDNSDomain(strDNSDomain) 'Turn on "Register this connection's addresses in DNS" and "Register this connection's DNS suffix in DNS registration". IPConfig.SetDynamicDNSRegistration bFullDNSRegistrationEnabled, bDomainDNSRegistrationEnabled Next 'Set the DNS suffix search list via the registry as SetDNSSuffixSearchOrder fails with "Invalid method" 'and EnableDNS doesn't seem to work. objShell.RegWrite "HKLM\SYSTEM\CurrentControlSet\services\Tcpip\Parameters\SearchList", strDNSSuffixSearchDomains, "REG_SZ" Set objWMIService = Nothing Set objShell = Nothing