Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Invalid Method error when trying to use SetDNSSuffixSearchOrder

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,32693
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Invalid Method error when trying to use SetDNSSuffixSearchOrder
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Invalid Method error when trying to use SetDNSSuffixSea... - 3/27/2006 3:12:25 AM   
  tboneking720

 

Posts: 6
Score: 0
Joined: 3/27/2006
Status: offline
    Hi, everybody.  I'm having issues trying to set the DNS suffix search order in VBScript.  I know I need to pass my variable in as an array of strings, but I can't find documentation anywhere explaining how to do that.  I'm using
SetDNSSuffixSearchOrder(strDNSSuffs)where I've tried setting strDNSSuffs as an array, a semicolon-delimited string, and just a variant, but none of these have worked.

Any ideas?

Thanks,
Greg Turnipseed
 
 
Post #: 1
 
 RE: Invalid Method error when trying to use SetDNSSuffi... - 3/27/2006 3:23:41 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
I realize that my rights to say this may have been revoked due to a question that I asked previously, but google is your friend. I searched for 'SetDNSSuffixSearchOrder' and this was the very first hit:

http://www.experts-exchange.com/Operating_Systems/Win2000/Q_20505817.html

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to tboneking720)
 
 
Post #: 2
 
 RE: Invalid Method error when trying to use SetDNSSuffi... - 3/27/2006 4:40:07 AM   
  tboneking720

 

Posts: 6
Score: 0
Joined: 3/27/2006
Status: offline
True, but they charge you.  :/

Thanks,
Greg Turnipseed

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: Invalid Method error when trying to use SetDNSSuffi... - 3/27/2006 4:42:55 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
No they don't...just scroll down the page.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to tboneking720)
 
 
Post #: 4
 
 RE: Invalid Method error when trying to use SetDNSSuffi... - 3/27/2006 5:18:22 AM   
  tboneking720

 

Posts: 6
Score: 0
Joined: 3/27/2006
Status: offline
When I click the link, it gives me the question, then has a large round orange button that says "view solution."  When I click it, it tells me I must be subscribed to view the solution.  Is it possible you're already a subscriber?

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: Invalid Method error when trying to use SetDNSSuffi... - 3/27/2006 5:19:59 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
I am not a member and I am not logged in. I see the huge orange button too. Just scroll down and you will see the discussion of the issue. Did you try scrolling down at all?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to tboneking720)
 
 
Post #: 6
 
 RE: Invalid Method error when trying to use SetDNSSuffi... - 3/28/2006 2:49:46 AM   
  tboneking720

 

Posts: 6
Score: 0
Joined: 3/27/2006
Status: offline
Of course I tried scrolling down!  I find your line of questioning insulting, but besides all that, it turns out it's a glitch in the link.  I viewed the page from a computer on a different network, and the rest of the page showed up.  Before, it stopped at the orange "ASK AN EXPERT NOW" link.  I just went back to the same page, and now the discussion is gone again.  :/

In any case, it doesn't answer the question of how to pass arrays of strings into a method.  I've tried using the array("string1","string2") before, but with no luck.  It keeps the variant typename, and the program gives me an error.

Thanks,
Greg Turnipseed

PS-sorry to be blunt, but your arguing with me as to whether the discussions exist or not is certainly not helpful to me, and accusing me of not taking the time to scroll down (which is, of course, the first thing I did...) insults me.

< Message edited by tboneking720 -- 3/28/2006 2:53:53 AM >

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: Invalid Method error when trying to use SetDNSSuffi... - 3/28/2006 2:56:32 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
My apologies for insulting you. I was simply confused since the entire discussion was right there plain as day for me.

Here is what I found to be pertinent:


Comment from TheMCSE
Date: 02/09/2003 09:14AM PST
Comment

Per the following MS documentation, the SetDNSSuffixSearchOrder method is specific to WinNT4.  The DNSDomainSuffixSearchOrder property should provide the functionality that you desire.  It looks like it accepts an array of strings for setting this property.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_networkadapterconfiguration.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/setdnssuffixsearchorder_method_in_class_win32_networkadapterconfiguration.asp

http://www.microsoft.com/technet/treeview/default.asp?url=/technet/ScriptCenter/network/ScrNet12.asp

Good luck.
Comment from stefri
Date: 02/09/2003 09:47AM PST
Author Comment

I realized that for Windows-NT-only was specified......

Is getting DNSDomainSuffixSearchOrder as follow will be successfull?

domSuff = colAdapt.DNSDomainSuffixSearchOrder
for i = 0 to ubound(domSuff)
  wscript.echo domSuff(i)
next

To clear:
domSuff = array("")
myErr = colAdapt.DNSDomainSuffixSearchOrder (domSuff)

To set:
domSuff = array("aa.bb.cc.com", "bb.cc.com", "cc.com")
myErr = colAdapt.DNSDomainSuffixSearchOrder (domSuff)

stefri
Comment from TheMCSE
Date: 02/09/2003 10:16AM PST
Comment

For getting the information, what you have should work.

  domSuff = colAdapt.DNSDomainSuffixSearchOrder
  for each item in domSuff
     MsgBox item
  next

I just noticed in the link I posted earlier that the DNSDomainSuffixSearchOrder is a read-only property.  I think that I would resort to modifying the registry (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\SearchList) to clear and set new suffix search order.

'********************************************************
Option Explicit
' On Error Resume Next

Const DESIRED_SEARCH_ORDER = "a.com,b.com,c.com,d.com"     ' registry expects comma delimited
Dim objWSHShell, strValue

Set objWSHShell = WScript.CreateObject("WScript.Shell")

strValue = objWSHShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\SearchList")
MsgBox "Your current DNS suffix search order contains: " & strValue & ".", vbInformation, "Current search order"

objWSHShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\SearchList", ""
strValue = objWSHShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\SearchList")
MsgBox "Your current DNS suffix search order contains: " & strValue & ".", vbInformation, "Current search order"

objWSHShell.RegWrite "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\SearchList", DESIRED_SEARCH_ORDER
strValue = objWSHShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\SearchList")
MsgBox "Your current DNS suffix search order contains: " & strValue & ".", vbInformation, "Current search order"
Comment from stefri
Date: 02/09/2003 10:23AM PST
Author Comment

A little more efforts and I double the points...
Could this be set in netlogon or whatever in such a way that changes are applied once and only once for all domain users when they will connect the firqt time. We are migrating to e2k and changing fixed IP address to DHCP, etc....
Stefri


Accepted Answer from TheMCSE
Date: 02/09/2003 01:23PM PST
Grade: A
Accepted Answer

Do your users have administrative permissions to the local machines?  If not, how do you plan on allowing the script to execute.  Excluding this one small detail, you could easily set a flag on the loal machine (in the filesystem?) to indicate whether the script had been executed.  A better way may be to put all of the code that you have for making the conversion into a sub and check one of the values that would be changed.  If it were all in a sub named ChangeNetSettings(), you could have something like this:

'*********************************************************

Sub ChangeNetSettings()
  ' Convert to DHCP, modify DNS, etc.
End Sub

Set objWSHShell = WScript.CreateObject("WScript.Shell")
On Error Resume Next
strValue = objWSHShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\SearchList")
If strValue = "" Or strValue <> "a.com,b.com,c.com,d.com" Then ChangeNetSettings()
Comment from stefri
Date: 02/10/2003 12:43AM PST
Author Comment

Thanks for your help. users will have permissions (unfortunately... otherwise there will 1500 PC to modify unless you have a suggestion for this small detail...as you say)

Follow this link: http://www.experts-exchange.com/Operating_Systems/Win2000/Q_20507140.html where more points are available
Stephane
Comment from stefri
Date: 02/10/2003 04:28AM PST
Author Comment

TheMCSE,
While browsing MSN, found this

[Visual Basic]

The EnableDNS WMI class static method enables the Domain Name System (DNS) for service.



Function EnableDNS( _
[ ByVal DNSHostName As String ], _
[ ByVal DNSDomain As String ], _
[ ByVal DNSServerSearchOrder() As String ], _
[ ByVal DNSDomainSuffixSearchOrder() As String ] _ as integer

To clear:
dnsSrch = array("")
domSuff = array("")
myErr = colAdapt.EnableDNS(,,dnsSrch ,domSuff)


To Set:

dnsSrch = array("172.0.0.1","172.1.0.1")
domSuff = array("a.b.com", "b.com")
myErr = colAdapt.EnableDNS(,,dnsSrch ,domSuff)

Will solve my problem?


Comment from TheMCSE
Date: 02/10/2003 05:53AM PST
Comment

Yes, this is definitely the correct way to use WMI to modify your DNS domain suffix search order.  You will have to adjust your code slightly to use this, as the EnableDNS method is called against the class (Win32_NetworkAdapterConfiguration).  Good luck.

sample at http://cwashington.netreach.net/depo/view.asp?Index=594&ScriptType=vbscript

'**********************************************************

dnsSuff = array("aa.bb.com", "bb.com")

Set objClass = GetObject("WinMGMTS:Win32_NetworkAdapterConfiguration")
objClass.EnableDNS ,,,dnsSuff

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to tboneking720)
 
 
Post #: 8
 
 RE: Invalid Method error when trying to use SetDNSSuffi... - 3/29/2006 1:06:25 AM   
  tboneking720

 

Posts: 6
Score: 0
Joined: 3/27/2006
Status: offline
Hey, these links helped a lot!  Thanks!
Greg Turnipseed

(in reply to ebgreen)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Invalid Method error when trying to use SetDNSSuffixSearchOrder Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts