Google Groupes n'accepte plus les nouveaux posts ni abonnements Usenet. Les contenus de l'historique resteront visibles.

SetDNSSuffixSearchOrder

250 vues
Accéder directement au premier message non lu

Carlos Fersura

non lue,
3 oct. 2002, 19:27:1303/10/2002
à
I have been able to configure my network adapter with the
exception of the DNSSufixSearchOrder. When I run the
method I get "Invalid Method (8004102E)". I am running
Windows 2000 SP3.

The code fragments is the following:

arrSufixes = Array("Mydomain.com", "myotherdomain.com")
For Each oAdapter in colNetAdapters
errEnable = oAdapter.EnableStatic(arrIP, arrSubnet)
errDNS = oAdapter.SetDNSServerSearchOrder(arrDNS)
errDNS = oAdapter.SetDNSSuffixSearchOrder(arrSufixes)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Next

Torgeir Bakken (MVP)

non lue,
3 oct. 2002, 20:00:0903/10/2002
à
Carlos Fersura wrote:

From "SetDNSSuffixSearchOrder Method in Class Win32_NetworkAdapterConfiguration"

http://msdn.microsoft.com/library/en-us/wmisdk/wmi/setdnssuffixsearchorder_method_in_class_win32_networkadapterconfiguration.asp

<qoute>
The SetDNSSuffixSearchOrder WMI class static method allows for the setting of
the suffix
search order as a array of elements. This is an instance-independent method call
that
applies across all adapters.
</qoute>

The error in your script, is that you use this SetDNSSuffixSearchOrder method on
the
instance. The doc above says "this is an instance-independent method ", that
means that
you need to use it on the class instead.

errDNS = oAdapter.SetDNSSuffixSearchOrder(arrSufixes)

you would need to use this instead

Set oClass = oWMI.Get(oAdapter.Path_.class)
errDNS = oClass.SetDNSSuffixSearchOrder(arrSufixes)


The same goes for EnableDNS method in class Win32_NetworkAdapterConfiguration:
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/enabledns_method_in_class_win32_networkadapterconfiguration.asp

It is an instance-independent method call that applies across all adapters,
just like SetDNSSuffixSearchOrder.

Here is the complete code that might work better (Note: Air code, not tested!):


sNode = "." 'use "." for local machine
Set oWMI = GetObject("winmgmts://" & sNode)

' only select adapters where ipEnabled is true
sQuery = "Select * From Win32_NetworkAdapterConfiguration" _
& " where ipEnabled = true"

Set colNetAdapters = oWMI.ExecQuery(sQuery)

arrIP = ...
arrSubnet = ...
arrDNS = ...


arrSufixes = Array("Mydomain.com", "myotherdomain.com")

For Each oAdapter in colNetAdapters
errEnable = oAdapter.EnableStatic(arrIP, arrSubnet)
errDNS = oAdapter.SetDNSServerSearchOrder(arrDNS)

Set oClass = oWMI.Get(oAdapter.Path_.class)
errDNS = oClass.SetDNSSuffixSearchOrder(arrSufixes)

If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed."
End If
Next


--
torgeir
Microsoft MVP Scripting and WMI
Porsgrunn Norway


0 nouveau message