Configure DNS suffix search order (VBScript)
This code can be found in
Chapter 1 of Windows Server 2003 Networking Recipes
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the VBScript code from this site.
' From the book "Windows Server 2003 Networking Recipes"
' This code will change the DNS suffix search order
' to "mycompany.com" followed by "east.mycompany.com"
' ------ SCRIPT CONFIGURATION ------
strComputer = "."
arrNewDNSSuffixOrder = Array("mycompany.com", "east.mycompany.com")
' --------- END CONFIGURATION ------
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set nics = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
Set Network = objWMIService.Get("Win32_NetworkAdapterConfiguration")
' now set the new DNS suffix search order
SetSuffixes = _
Network.SetDNSSuffixSearchOrder(arrNewDNSSuffixOrder)
If SetSuffixes = 0 Then
WScript.Echo "Success! Replaced DNS domain suffix search order."
ElseIf SetSuffixes = 1 Then
WScript.Echo "Success! Replaced DNS domain suffix search order – pls. reboot."
Else
WScript.Echo "Error! Unable to replace DNS domain suffix search order list."
End If
|
This code has been viewed 5602 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|