Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
obj.DNSDomainSuffixSearchOrder = myarray
In other words, you should be able to place the DNS domain names in a regular WIL array and call the "SetDNSSuffixSearchOrder" method directly. Something like this:
; Note: this example has not been tested. ; Create an array of DNS domain names aDNS = ArrDimension(2) aDNS[0] = "hr.fabrikam.com" aDNS[1] = "research.fabrikam.com" ; Call the method directly. nResult = objNetworkSettings.SetDNSSuffixSearchOrderobj(aDNS)
If you have an older version of the software...(which you must because of the error you are seeing.)
"DNSDomainSuffixSearchOrder" is a read-only property. To set the property you need to user the method "SetDNSSuffixSearchOrder" which accepts an array of suffixes as it's only parameter.
It should look something like this:
strComputer = "." objWMIService = GetObject("winmgmts:\\%strComputer%\root\cimv2") objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration") arrDNSSuffixes = ArrDimension(2) arrDNSSuffixes[0] = "hr.fabrikam.com" arrDNSSuffixes[1] = "research.fabrikam.com" objNetworkSettings.SetDNSSuffixSearchOrder(arrDNSSuffixes)because "SetDNSSuffixSearchOrder" is a method not a property.
However, this does not work because the type information for the "SetDNSSuffixSearchOrder" method appears to be missing from the object. You will get an type mismatch error if you try it ( I know, back were we started.)
At this point the best advice I have is to create a WSC file which would allow you to call the method in VB from a WB. If I get a chance I will put something together and post it later today.
I am not sure what we need to do in WB to make this method work but it will get looked into.
Attached is an ugly hack that will enable you to use the "SetDNSSuffixSearchOrder" method in WB. The "SetDnsSrch.wsc" file contains a component written in VBS. The second file is a sample script that makes use of the component created in the first file. (Many thanx to Stan L. for first pointing out this technique.)
SETDNSSRCH.WBT
sComponentFile = StrCat("c:\projects\automation\test\","SetDnsSrch.wsc") ; Create a VBS component. sComponentFile = "c:\projects\automation\test\SetDnsSrch.wsc" If ! FileExist(sComponentFile) message("Error:","Cannot locate SetDnsSrch.wsc" ) Exit Endif sComponentFile= StrCat("script:",sComponentFile) oObj = GetObject(sComponentFile) strComputer = "." objWMIService = GetObject("winmgmts:\\%strComputer%\root\cimv2") objNetworkSettings = objWMIService.Get("Win32_NetworkAdapterConfiguration") ; Use the component to call the problematic method. nResult = oObj.SetDnsSrch(objNetworkSettings ,"hr.fabrikam.com","research.fabrikam.com") message("nResult", nResult) oObj = 0 objWMIService = 0 objNetworkSettings = 0 exitSETDNSSRCH.WSC (VBS component)
<?xml version="1.0"?> <component> <?component error="true" debug="true"?> <registration description="SetDnsSrch" progid="SetDnsSrch.WSC" version="1.00" classid="{D8494A23-3082-4eda-B77B-24474C8EAA8C}" > </registration> <public> <method name="SetDnsSrch"> <PARAMETER name="netobj"/> <PARAMETER name="dns1"/> <PARAMETER name="dns2"/> </method> </public> <implements type="Behavior" id="Behavior"/> <script language="VBScript"> <![CDATA[ function SetDnsSrch(netobj,dns1,dns2) arr = Array(dns1, dns2) SetDnsSrch = netobj.SetDNSSuffixSearchOrder(arr) 'MsgBox(dns1) end function ]]> </script> </component>
Article ID: W16755
File Created: 2005:02:18:12:22:14
Last Updated: 2005:02:18:12:22:14