Hi Everyone,
I know this is a bit of an off topic on this mail group but I’ve seen some
WMI stuff go by in the past and receive some useful information. What I’m
trying to do is write a WSH script to configure the network settings for an
Adapter. So far I’ve been able to get the script to switch between Static
and Dynamic IP configuration, however I seem to be having trouble getting it
to configure DNS and WINS. Each type I go to perform the configuration I
receive an “Invalid Method” (Code 8004102E). Has anyone come across this
before? There’s not a whole lot of examples out there for this specific
function.
DNS1 = “1.1.1.1”
DNS2 = “1.1.1.2”
DNS3 = “1.1.1.3”
DNSDomainName = “Foo.com”
DNSHostName = “host”
NICNUMBER=1
'Setup Objects
'INIT a WMIObject
Set oLocator = wscript.CreateObject(“WbemScripting.SWbemLocator”)
'Connect to the WMI root
Set oServices = oLocator.ConnectServer(, “root\cimv2”)
'Attach to the Win32_NetworkAdapterConfiguration WMI Object for the
specified NIC instance
Set oObject = oServices.Get(“Win32_NetworkAdapterConfiguration.Index=” &
NICNUMBER)
'Setup the EnableDNS method to be able to retreive the input params
Set oMethod = oObject.Methods_(“EnableDNS”)
'Retreive the input params for the EnableDNS Method
Set inParam = oMethod.InParameters.SpawnInstance_()
'Put the DNS Servers & the DNSSuffixSearchOrderNames into an Array
aDNSServers = Array(DNS1,DNS2,DNS3)
DNSDomainSuffixSearchOrder=Array(DNSDomainName)
'Setup the input params for the DNS Configuration
inParam.DNSHostName = DNSHostName
inParam.DNSDomain = DNSDomainName
inParam.DNSServerSearchOrder = aDNSServers
inParam.DNSDomainSuffixSearchOrder = DNSDomainSuffixSearchOrder
'Setup the DNS Configuration!
Set ReturnResult = oObject.ExecMethod_(“EnableDNS”, inParam)
Thanks,
Yousef Hamade
xxxxx@fmr.com