Configure WINS servers (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 configures two WINS servers
' ------ SCRIPT CONFIGURATION ------
strComputer = "."
strWins1 = "192.168.1.151"
strWins2 = "192.168.1.152"
' --------- 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
  intSetWINS = nic.SetWINSServer(strWINS1, strWINS2)
  If intSetWINSServer = 0 Then
    WScript.Echo "Success! WINS servers configured."
  ElseIf intSetWINSServer = 1 Then
    WScript.Echo "WINS servers configured, please reboot."
  Else
    WScript.Echo "Error!! Unable to configure WINS servers."
  End If
Next

This code has been viewed 2050 times.

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