Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > problem with SetDNSServerSearchOrder WMI function

Reply
Thread Tools Display Modes

problem with SetDNSServerSearchOrder WMI function

 
 
James
Guest
Posts: n/a

 
      09-26-2008
uint32 SetDNSServerSearchOrder(
[in] string DNSServerSearchOrder[]
);

above is copy/paste from msdn site on this function. I keep getting error
70, which means invalid IP address but I know the IP's I'm supplying are
fine. The site said that it takes a 'list' of ip addresses but fails to
mention how that list should be delimited.. I've tried comma and space and
'or' with no luck, same error every time.

here is a snippet of my code, including some temp debugging stuff:
----------------------------------

Dim temp
aDNSServers = Array(PrimaryDNS & "," & SecondaryDNS)
For Each temp In aDNSServers
MsgBox temp
Next

sQuery = "SELECT MACAddress FROM Win32_NetworkAdapterConfiguration WHERE
IPEnabled = TRUE"

set colAdapters = oWMI.ExecQuery(sQuery)

For Each oAdapter In colAdapters 'all the NICs in the machine
MsgBox "configuring: " & oAdapter.MACAddress
iRetVal = oAdapter.SetDNSServerSearchOrder(aDNSServers)

If iRetVal = 0 Then
msgbox "DNS servers set."
Else
msgbox "possible error setting dns servers: " & iRetval
End If
next
-------------------------------------

aDNSServers contains 2 ipaddresses delimited by a comma. This has been
verified with my debugging msgboxs at runtime.

what am I missing here?


 
Reply With Quote
 
 
 
 
J Ford
Guest
Posts: n/a

 
      09-26-2008
I have had problems in the past when trying to set something and using a
specific select statement ie "SELECT MACAddress...", but when I have done
"SELECT *..." it worked.

-J

"James" wrote:

> uint32 SetDNSServerSearchOrder(
> [in] string DNSServerSearchOrder[]
> );
>
> above is copy/paste from msdn site on this function. I keep getting error
> 70, which means invalid IP address but I know the IP's I'm supplying are
> fine. The site said that it takes a 'list' of ip addresses but fails to
> mention how that list should be delimited.. I've tried comma and space and
> 'or' with no luck, same error every time.
>
> here is a snippet of my code, including some temp debugging stuff:
> ----------------------------------
>
> Dim temp
> aDNSServers = Array(PrimaryDNS & "," & SecondaryDNS)
> For Each temp In aDNSServers
> MsgBox temp
> Next
>
> sQuery = "SELECT MACAddress FROM Win32_NetworkAdapterConfiguration WHERE
> IPEnabled = TRUE"
>
> set colAdapters = oWMI.ExecQuery(sQuery)
>
> For Each oAdapter In colAdapters 'all the NICs in the machine
> MsgBox "configuring: " & oAdapter.MACAddress
> iRetVal = oAdapter.SetDNSServerSearchOrder(aDNSServers)
>
> If iRetVal = 0 Then
> msgbox "DNS servers set."
> Else
> msgbox "possible error setting dns servers: " & iRetval
> End If
> next
> -------------------------------------
>
> aDNSServers contains 2 ipaddresses delimited by a comma. This has been
> verified with my debugging msgboxs at runtime.
>
> what am I missing here?
>
>
>

 
Reply With Quote
 
James
Guest
Posts: n/a

 
      09-26-2008
Thanks for the reply J Ford. I appreciate it. That has happened to me before
also and I didn't even think to try that for this one... turned out to not
be the issue in this case but I appreciate the good advice none the less.

In this case it turns out I'm an idiot (again)

this line:
aDNSServers = Array(PrimaryDNS & "," & SecondaryDNS)

is the problem. Even know I knew the IPs I was supplying were valid I
screwed up making the array. Above produces array with one element
containing a string with both IP's seperated by the comma. Improper use of
the array function. Should be this:

aDNSServers = Array(PrimaryDNS, SecondaryDNS)

and works fine when it is.




"J Ford" <> wrote in message
news:7F2ACC92-FF10-4831-9C19-...
>I have had problems in the past when trying to set something and using a
> specific select statement ie "SELECT MACAddress...", but when I have done
> "SELECT *..." it worked.
>
> -J
>
> "James" wrote:
>
>> uint32 SetDNSServerSearchOrder(
>> [in] string DNSServerSearchOrder[]
>> );
>>
>> above is copy/paste from msdn site on this function. I keep getting error
>> 70, which means invalid IP address but I know the IP's I'm supplying are
>> fine. The site said that it takes a 'list' of ip addresses but fails to
>> mention how that list should be delimited.. I've tried comma and space
>> and
>> 'or' with no luck, same error every time.
>>
>> here is a snippet of my code, including some temp debugging stuff:
>> ----------------------------------
>>
>> Dim temp
>> aDNSServers = Array(PrimaryDNS & "," & SecondaryDNS)
>> For Each temp In aDNSServers
>> MsgBox temp
>> Next
>>
>> sQuery = "SELECT MACAddress FROM Win32_NetworkAdapterConfiguration WHERE
>> IPEnabled = TRUE"
>>
>> set colAdapters = oWMI.ExecQuery(sQuery)
>>
>> For Each oAdapter In colAdapters 'all the NICs in the machine
>> MsgBox "configuring: " & oAdapter.MACAddress
>> iRetVal = oAdapter.SetDNSServerSearchOrder(aDNSServers)
>>
>> If iRetVal = 0 Then
>> msgbox "DNS servers set."
>> Else
>> msgbox "possible error setting dns servers: " & iRetval
>> End If
>> next
>> -------------------------------------
>>
>> aDNSServers contains 2 ipaddresses delimited by a comma. This has been
>> verified with my debugging msgboxs at runtime.
>>
>> what am I missing here?
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function problem with keyboard Paul Windows Vista Hardware 1 09-04-2008 11:48 PM
Keyboard second function problem lawrie Windows Vista Hardware 1 06-14-2008 12:52 PM
Re: Problem with zoom function Frank Saunders, MS-MVP OE/WM Internet Explorer 0 01-13-2007 08:54 PM
Function Keys Problem Viperking Internet Explorer 1 02-22-2006 06:18 PM
Re: WMI SetDNSServerSearchOrder Mike Lin Scripting 0 06-30-2003 09:44 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59