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
$objWMIData = GetObject('winmgmts:{impersonationLevel=impersonate}!//' + $strItem + '/root/cimv2')
$colWMIData = $objWMIData.ExecQuery('SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True')
For Each $strQuery in $colWMIData
$SetDNS = $strQuery.SetDNSServerSearchOrder($astrDNS)
If $SetDNS = 0
$txtResults.appendtext("Success" + @CRLF)
EndIF
$txtResults.appendtext($strQuery.WINSPrimaryServer + @CRLF)
$txtResults.appendtext($strQuery.WINSSecondaryServer + @CRLF)
For Each $strDNS in $strQuery.DNSServerSearchOrder
$txtResults.appendtext($strDNS + @CRLF)
Next
Next
Next
$frmOptions.Hide
EndFunction
Above is the code to change the DNS servers via WMI but when you list them right after the change they don't refresh, yet on the machine they refresh, which is cool cause it works, only way I have to check that it worked is to check the error code it returns...
Edited by supermanzdead (2005-04-07 04:36 AM)
_________________________
~Mwah