Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - problem with SetDNSServerSearchOrder WMI function

Reply
 
Old 09-25-2008   #1 (permalink)
James


 
 

problem with SetDNSServerSearchOrder WMI function

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?



My System SpecsSystem Spec
Old 09-26-2008   #2 (permalink)
J Ford


 
 

RE: problem with SetDNSServerSearchOrder WMI function

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:
Quote:

> 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?
>
>
>
My System SpecsSystem Spec
Old 09-26-2008   #3 (permalink)
James


 
 

Re: problem with SetDNSServerSearchOrder WMI function

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" <JFord@xxxxxx> wrote in message
news:7F2ACC92-FF10-4831-9C19-C3EA98B8F8B2@xxxxxx
Quote:

>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:
>
Quote:

>> 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?
>>
>>
>>

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
win32_pingstatus and function problem PowerShell
Function problem with keyboard Vista hardware & devices
Problem using split function VB Script
Keyboard second function problem Vista hardware & devices
Problem with Vista's sleep function Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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