Petri.co.il forums Home Forums Start Page Forums Frequently Asked Questions FAQ Member List Members List
Go Back   Petri IT Knowledgebase Forums > Windows Scripting > General Scripting
Petri.co.il is happy to award RicklesP the title of Most Valuable Member !!!
Register Calendar Calendar Search Petri IT Knowledgebase Forums Search Todays Posts Today's Posts Mark Forums Read
Notices

DNS IP configuration to all clients by VBscript

DNS IP configuration to all clients by VBscript

this thread has 2 replies and has been viewed 21225 times

Closed Thread
 
Thread Tools Search this Thread Display Modes
  #1  
Old 22nd July 2007, 13:53
mcse2003 mcse2003 is offline
Casual
Casual
 
 Join Date: Jan 2007
  6 month star 12 month star
 Posts: 2
 Reputation: mcse2003 is on a distinguished road (10)
Default DNS IP configuration to all clients by VBscript

Dear Members,


I need some help regarding DNS IP configuration to all my clients(windows xp pro)
I want to build vbscript to enable me to distribute it

My scope of work is:

In every brunch I have 15 clients, I need to setup a script that change my dns ip configuration priority in the network adapters.


Thank You
Yours
Ron
  #2  
Old 22nd July 2007, 16:56
PaulH's Avatar
PaulH PaulH is offline
Member
Someone to look up to
 
 Join Date: Feb 2007
  6 month star 12 month star
 Location: North Yorkshire, UK
 Posts: 815
 Reputation: PaulH has a spectacular aura aboutPaulH has a spectacular aura aboutPaulH has a spectacular aura about (209)
Default Re: DNS IP configuration to all clients by VBscript

Not VBScript, I realise, but it may be useful for you to have a look at this command line, which saves IP configuration including DNS:

Code:
netsh -c interface dump > settings.txt
So, have a look at the settings.txt file and see how it works. Then, this command will fetch those settings and load them into the network settings:
Code:
netsh -f settings.txt
So you could make a batch file using the above command for your use and run it accordingly (at startup, logon etc).
__________________
Best wishes,
PaulH.
MCP:Server 2003; MCITP:Server 2008; MCTS: SBS2008
  #3  
Old 8th August 2007, 19:34
Rems's Avatar
Rems Rems is offline
Moderator
 
 Join Date: Mar 2005
  6 month star 12 month star
 Location: NL
 Posts: 2,405
 Reputation: Rems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to beholdRems is a splendid one to behold (944)
Default Re: DNS IP configuration to all clients by VBscript

add this vbs-code to the Computer - Startup script:
Code:
'http://msdn2.microsoft.com/en-US/library/aa393295.aspx
'http://www.microsoft.com/technet/scriptcenter/resources/qanda/apr05/hey0425.mspx


arrNewDNSServerSearchOrder = Array( "192.168.1.3", _
                                    "192.168.1.4"  )
                                    
'to find the right adapter(s) to change:
strOneOfTheOldDNSServers = "192.168.1.2"


strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")


Set colNetCards = objWMIService.ExecQuery _
    ("Select DNSServerSearchOrder From Win32_NetworkAdapterConfiguration")

For Each objNetCard in colNetCards
  blnFound = 0
  arrDNSServerSearchOrder = objNetCard.DNSServerSearchOrder
  If Not IsNull(arrDNSServerSearchOrder) Then
    For i = 0 to UBound(arrDNSServerSearchOrder)
      If (arrDNSServerSearchOrder(i) = strOneOfTheOldDNSServers) Then
        arrDNSServerSearchOrder = Array()
        objNetCard.SetDNSServerSearchOrder(arrDNSServerSearchOrder)
        wscript.sleep 600
        arrDNSServerSearchOrder = arrNewDNSServerSearchOrder
        objNetCard.SetDNSServerSearchOrder(arrDNSServerSearchOrder)
        Exit For
      End If
    Next    
  End If
Next
\Rems
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
b-focus 270 pr - dns configuration galtlor DSL, Cable, and other Broadband Issues 1 30th May 2007 01:10
Changing DNS of all XP clients with new DNS in AD win2003 try Windows 2000 Pro, XP Pro 4 30th August 2006 12:39
how to configure DNS to update clients dns automatically jjaanus Windows Server 2000 / 2003 / 2003 R2 4 25th November 2004 16:42
DNS Internet Configuration: effy_t Windows Server 2000 / 2003 / 2003 R2 1 12th September 2004 23:53
DNS site configuration jaalvaro Active Directory 0 27th August 2004 13:36


All times are GMT +3. The time now is 12:46.

Steel Blue 3.5.4 vBulletin Style ©2006 vBEnhanced
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
 

Valid XHTML 1.0!   Valid CSS!

Copyright 2005 Daniel Petri