Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old May 2nd, 2004, 07:07 PM
Half-Crazed Half-Crazed is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 Half-Crazed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
.reg script to change DNS servers.

I need a registry script (or something like it) to easy change the computer's set DNS servers. The problem I am having is that the nameserver value is in a key whos name is set by the network adapter. Because of this, I am not able to make a script that will work on multiple computers without putting the key name in manually. So far I have this:

REGEDIT4

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces\--keynamehere--\Nameserver]
"NameServer"="11.22.33.44"

Is there any way I can set --keynamehere-- to be all keys withing the \interfaces\ directory? If so, how? If not, how should I go about making an easy/quick way to change the DNS servers?

Thanks in advance,

Alex

Reply With Quote
  #2  
Old May 10th, 2004, 03:57 PM
mjm1231 mjm1231 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 14 mjm1231 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 45 m 12 sec
Reputation Power: 0
I was searching for a solution to this same problem today. The way you worded the question inspired me to find a way to enumerate only those interfaces that have IP addresses (which for most people is what you want here).

This should do the trick:


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set WshShell = WScript.CreateObject("WScript.Shell")
DNSserv= "11.22.33.44"
Regkey = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces\"

Set IPDevSet = objWMIService.ExecQuery _
("Select SettingID from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

For Each IPDev in IPDevSet
'Combine regkey, settingID, and nameserver to create the correct registry key path
WshShell.RegWrite Regkey & IPDev.SettingID & "\NameServer", DNSserv, "REG_SZ"
Next

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > .reg script to change DNS servers.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway