Code:

Function CommitOptionsWMI()
Dim $strDNS1, $strDNS2, $strWINS1, $strWINS2, $strComputers, $astrDNS[1]
$strDNS1 = $txtDNS1.text
$strDNS2 = $txtDNS2.text
$strWINS1 = $txtWINS1.text
$strWINS2 = $txtWINS2.text
$astrDNS[0] = $strDNS1
$astrDNS[1] = $strDNS2
$strComputers = $txtComputers.text
$astrComputers = Split($strComputers, @CRLF)
For Each $strItem in $astrComputers
$txtResults.appendtext("Changing DNS and WINS on " + $strItem + "..." + @CRLF)
$objWMIData = GetObject('winmgmts:{impersonationLevel=impersonate}!//' + $strItem + '/root/cimv2')
If @Error = 0
$colWMIData = $objWMIData.ExecQuery('SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True')
For Each $strQuery in $colWMIData
$SetDNS = $strQuery.SetDNSServerSearchOrder($astrDNS)
$SetWINS = $strQuery.SetWINSServer($strWINS1, $strWINS2)
Select
Case $SetDNS = 0 and $SetWINS = 0
$txtResults.appendtext(" " + $strItem + " has had a successful change" + @CRLF)
Case $SetDNS = 1 or $SetDNS = 1
$txtResults.appendtext(" " + $strItem + " requires a restart!" + @CRLF)
Case 1
$txtResults.appendtext(" " + $strItem + " has other problems and needs research!" + @CRLF)
EndSelect
Next
Else
$txtResults.appendtext(" " + $strItem + " needs to have WMI checked!")
EndIf
Next
$frmOptions.Hide
EndFunction



My final UDF, just have to add some error checking as far as the format of the addresses and computer name

Thanks everyone for your help, I would like some feedback if you have time to look at the code.


Edited by supermanzdead (2005-04-07 04:36 AM)