|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
.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 |
|
#2
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Web Site Management > Scripts > .reg script to change DNS servers. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|