Enable dynamic DNS (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 enables dynamic DNS registration on each NIC
' installed in the local computer
' ------ SCRIPT CONFIGURATION ------
  strComputer = "."
  boolEnabled = True
' ------ END CONFIGURATION ---------

Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set nics = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

For Each nic In nics
  intDynamicRegistration = nic.SetDynamicDNSRegistration _
   (boolEnabled, boolEnabled)
  If intDynamicRegistration = 0 Then
    WScript.Echo VbCrLf & "Success! Dyamic Registration enabled!"
  ElseIf intDynamicRegistration = 1 Then
    WScript.Echo "Success! Dynamic Registration enabled! Please reboot."
  Else
    WScript.Echo "Error! Unable to enable Dynamic Registration."
  End If
Next

This code has been viewed 1614 times.

New from the creators of TechTasks.com: StatSheet.com