#92994 - 2003-09-28 08:56 AM
Set DNS Search Order
|
neg604
Fresh Scripter
Registered: 2003-09-28
Posts: 6
|
Am trying to change DNS search order
$strComputer = "." $objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"+$strComputer+"\root\cimv2") $DNSAdapterSet = $objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE AND Description<>'PPP Adapter.' AND Description<>'Windows NT Remote Access WAN Wrapper'") Dim $DNSip[4] $DNSip[1] = '157.54.164.1' $DNSip[2] = '157.54.164.2' $DNSip[3] = '157.54.164.3' $DNSip[4] = '157.54.164.4'
For Each $DNSAdapter In $DNSAdapterSet
$result = $DNSAdapter.SetDNSServerSearchOrder($DNSip)
If $result = 0 $null = MessageBox(@SERROR+"["+$result+"]", $DNSAdapter.IPAddress(0), 16) Else $null = MessageBox("IP Change failed."+" "+$result, $DNSAdapter.IPAddress(0), 16) EndIf Next
and i get COM exception error "SetDNSServerSearchOrder" (SWbemObject - Type mismatch ) [-2147352567/80020009]
Any ideas?
(This Board is just wonderfull)
|
Top
|
|
|
|
#92998 - 2003-09-28 09:29 AM
Re: Set DNS Search Order
|
neg604
Fresh Scripter
Registered: 2003-09-28
Posts: 6
|
same error
i try also one ip only and i take also the same message
|
Top
|
|
|
|
#92999 - 2003-09-28 09:32 AM
Re: Set DNS Search Order
|
neg604
Fresh Scripter
Registered: 2003-09-28
Posts: 6
|
if i try to change (with another function) the current domain suffix (that expects string) the change takes effect immediatly.
The "SetDNSServerSearchOrder" expects some specific type of input i think that after many many test can't find.
|
Top
|
|
|
|
#93004 - 2003-09-28 11:07 AM
Re: Set DNS Search Order
|
neg604
Fresh Scripter
Registered: 2003-09-28
Posts: 6
|
be more specific (you mean with registry key?)
|
Top
|
|
|
|
#93006 - 2003-09-28 11:30 AM
Re: Set DNS Search Order
|
neg604
Fresh Scripter
Registered: 2003-09-28
Posts: 6
|
the "be more specific " goes to "before I do that and change my own DNS settings, why you don't change the settings with kix without com?" and not to UDF.
Are you a little suspicious about me. You think that am newbee and i want to ask you how can i modify registry?(reminds me microsoft "modify at your own risk")
My first question is about WMI method. Thanks for your try.I like short code is more simple to support my 2500 users with wmi functions than with one UDF with 2 pages of code.
Thanks ,
|
Top
|
|
|
|
#93008 - 2003-09-29 12:09 AM
Re: Set DNS Search Order
|
Yiannis
Lurker
Registered: 2002-09-06
Posts: 4
Loc: Athens
|
finaly i find my proper username for this board
|
Top
|
|
|
|
#93011 - 2003-09-29 08:52 AM
Re: Set DNS Search Order
|
Yiannis
Lurker
Registered: 2002-09-06
Posts: 4
Loc: Athens
|
sealeopard - You've right about index. I modify the script but same error.(but i thing you know that already)
|
Top
|
|
|
|
#93012 - 2003-09-29 09:38 AM
Re: Set DNS Search Order
|
Yiannis
Lurker
Registered: 2002-09-06
Posts: 4
Loc: Athens
|
Something wrong must be on arrays of kix.Or something wrong with my mind.Whatever here are one windows scripting host script i found (seems to be correct)
sNameSpace = "root/CIMV2" sTargetClass = "Win32_NetworkAdapterConfiguration" sClass = "Win32_NetworkAdapter" sProperty1 = "AdapterType" sValue1 = "Ethernet 802.3" sProperty2 = "NetConnectionStatus" iValue2 = 2
sComputer = "SWYNKPC0001" sPriWINS = "1.2.3.4" sSecWINS = "1.2.4.3" aDNSServers = Array("1.2.2.1","1.2.3.5") sDNSDomain = "swynk.com" iNetBIOS = 1
sWQLQuery = "SELECT * FROM " & sClass & " WHERE " & sProperty1 & "=" & Chr(34) & sValue1 & Chr(34) & _ " AND " & sProperty2 & "=" & iValue2
Set cInstances = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _ sComputer & "/" & sNameSpace).ExecQuery(sWQLQuery, "WQL")
For Each oInstance In cInstances Set cAssociators = oInstance.Associators_(,sTargetClass) For Each oAssociator In cAssociators Set oMethod = oAssociator.Methods_("SetWINSServer") Set oInParam = oMethod.InParameters.SpawnInstance_() oInParam.WINSPrimaryServer = sPriWINS oInParam.WINSSecondaryServer = sSecWINS Set oOutParam = oAssociator.ExecMethod_("SetWINSServer", oInParam)
If oOutParam.returnValue = 0 Then WScript.Echo UCase("SetWINSServer") & " method completed successfully" Else WScript.Echo UCase("SetWINSServer") & " method failed. Error Number " & oOutParam.returnValue End If
Set oMethod = oAssociator.Methods_("SetDNSServerSearchOrder") Set oInParam = oMethod.InParameters.SpawnInstance_() oInParam.DNSServerSearchOrder = aDNSServers Set oOutParam = oAssociator.ExecMethod_("SetDNSServerSearchOrder", oInParam)
If oOutParam.returnValue = 0 Then WScript.Echo UCase("SetDNSServerSearchOrder") & " method completed successfully" Else WScript.Echo UCase("SetDNSServerSearchOrder") & " method failed. Error Number " & oOutParam.returnValue End If
Set oMethod = oAssociator.Methods_("SetDNSDomain") Set oInParam = oMethod.InParameters.SpawnInstance_() oInParam.DNSDomain = sDNSDomain Set oOutParam = oAssociator.ExecMethod_("SetDNSDomain", oInParam)
If oOutParam.returnValue = 0 Then WScript.Echo UCase("SetDNSDomain") & " method completed successfully" Else WScript.Echo UCase("SetDNSDomain") & " method failed. Error Number " & oOutParam.returnValue End If
Set oMethod = oAssociator.Methods_("SetTCPIPNetBIOS") Set oInParam = oMethod.InParameters.SpawnInstance_() oInParam.TcpipNetBIOSOptions = iNetBIOS Set oOutParam = oAssociator.ExecMethod_("SetTCPIPNetBIOS", oInParam)
If oOutParam.returnValue = 0 Then WScript.Echo UCase("SetTCPIPNetBIOS") & " method completed successfully" Else WScript.Echo UCase("SetTCPIPNetBIOS") & " method failed. Error Number " & oOutParam.returnValue End If
Next Next
(http://www.serverwatch.com/tutorials/article.php/1556311)
y can not do the same with kix???????????
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 248 anonymous users online.
|
|
|