|
|
|||||||
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) |
||||||||
|
|
|||||||
wonderfull board? well said after one post anyway, you are feeding it an kixtart array, thus it cries, I bet. what you really should feed to it? |
||||||||
|
|
|||||||
Please look at the following address..... Am thinking that the function SETDNSSERVERSEARCH ORDER waits for an array.But did not accepts either a string. http://msdn.microsoft.com/library/en-us/wmisdk/wmi/setdnsserversearchorder_method_in_class_win32_networkadapterconfiguration.asp?frame=true I have make only one post but am reading other posts for about 2 years. |
||||||||
|
|
|||||||
did you try with: code:Dim $DNSip= |
||||||||
|
|
|||||||
same error i try also one ip only and i take also the same message |
||||||||
|
|
|||||||
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. |
||||||||
|
|
|||||||
well, re-read the page: quote:string can't be anything funky. |
||||||||
|
|
|||||||
ok, I found a proper way for methods. wait a sec will write test script. |
||||||||
|
|
|||||||
before I do that and change my own DNS settings, why you don't change the settings with kix without com? |
||||||||
|
|
|||||||
here is code by sealeopard that can do other shit too: http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000148 |
||||||||
|
|
|||||||
be more specific (you mean with registry key?) |
||||||||
|
|
|||||||
not sure how specific I should be. I can't start explaining the code, that would take 2 hours. but, indeed it uses registry. and it's not the simpliest UDF's I've seen. JENS, you there? what more info about it you want? |
||||||||
|
|
|||||||
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 , |
||||||||
|
|
|||||||
ja, that UDF is sad show. it probably would be just some lines for this task if someone else would have written it anyway, the WMI way I have partly generated. I was able to lock myself offline with this: dunno what inparam property I should put there. anyway, my ironic note about the UDF (which you understood to point to registry stuff in it) was a pointer for you to try descripe a little more specific question |
||||||||
|
|
|||||||
finaly i find my proper username for this board |
||||||||
|
|
|||||||
Yiannis, Just how does this information you shared with us relate to this thread? Please refer to the board etiquette... in paticular, section I. Topic: ABC's of KiXtart board etiquette and message to new forum users |
||||||||
|
|
|||||||
One of the problems in the initial code is that KiXtart arrays start with index 0, however, there's no IP address assigned to index 0. |
||||||||
|
|
|||||||
sealeopard - You've right about index. I modify the script but same error.(but i thing you know that already) |
||||||||
|
|
|||||||
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??????????? |
||||||||
|
|
|||||||
ok, looking at the codes you posted, my code does not need nothing else than the line I said it lacked. but, as you say, something is screwed. it gives returnvalue of 0, thus it should work but indeed it removes all my servers |
||||||||
|
|
|||||||
Have you tried it with just one IP address? |
||||||||
|
|
|||||||
not sure did you ask me, but yes. return code success and all dns-servers removed. |