Home » Scripting » Need help with this script to change DNS/WINS Messages in this topic - RSS
|
12/18/2011 7:07:58 PM
certifiedgeek05
certifiedgeek05
Posts 4
Hello,
I have been working on this script for a couple and can't seen to get it to work. All the parts of the script seem valid. If anyone can lend an Eye that would be awesome. Suggestings are welcome.

I am trying to:
1. Set DNS and WINS
2. Apply it only to a named NIC
3. Would love to have some error logging.

Here is the script.


On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

strDNS1 = "192.168.20.150"
strDNS2 = "192.168.20.41"
strWins1 = "192.168.20.150"
strWins2 = "192.168.20.41"

Set colNicConfigs = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID = 'CFN'",,48)

For Each objNicConfig In colNicConfigs
arrDNSServers = Array(strDNS1, strDNS2)
objNicConfig.SetDNSServerSearchOrder(arrDNSServers)
intSetWINS = objNicConfig.SetWINSServer(strWINS1, strWINS2)
'If intSetWINSServer = 0 Then
'WScript.Echo "Success! WINS & DNS servers configured."
'ElseIf intSetWINSServer = 1 Then
'WScript.Echo "WINS & DNS servers configured, please reboot."
'Else
'WScript.Echo "Error!! Unable to configure WINS & DNS servers."
'End If
Next

edited by certifiedgeek05 on 12/18/2011
pages: 1
|

Home » Scripting » Need help with this script to change DNS/WINS