Find and Replace Registry Keys from a Command Line

by Len Parov.

Share
|
Homepage | Submit your article | Contact | TOS
More articles on microsoft os family  

You are here: Categories » » Microsoft OS family

Using the Regfind utility, you can easily search the Registry for a value, regardless of the key, and replace it.

Regfind (from the Windows 2000 Server Resource Kit) can be an invaluable tool when you need change a Registry key that you know the value for but when do not necessarily know the full path. Recently tasked with changing the hardcoded DNS server IP on all the servers in our organization, I was pleasantly surprised when I located this gem. The problem with trying to change the DNS server entry in the Registry is that all the IP parameters are broken up by a hashed ID. The ID references several things, but most of them have to do with the network card. Regfind allows you to search a set of subkeys in the Registry for a specific value and, when found, replace it. Another real beauty of this program is that it will work remotely; all you need to do is supply it with a list of machines and let it go. Using a list of computer names (generated from SMS, Server Manager, or AD Users and Computers), combined with two batch files, you can make sweeping changes in a dynamic environment.

The Code

Here's an example of how to change the DNS server entry on all servers in your organization. First, create a batch file called Regchange2.bat with the following syntax:

regfind -m \\%1 -p HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\parameters "OLDIP" -r "NEWIP"

You will obviously want to replace OLDIP with the old DNS server IP and replace NEWIP with the new DNS server IP.

Now, create a second batch file called regchange1.bat with the following syntax:

for /F %%A in (servers.txt) do (call regchange2.bat %%A)

This searches the servers.txt file for computer names and passes them to the regchange2.bat file as a command-line argument.

Now you need to create a list file for your batch files to use. Create a listing of servers that need to have their DNS IP's changed and save that list as servers.txt. An SMS report or a copy/paste from the server manager will suffice, or you can create the file manually if you like.

Running the Hack

Now, simply run the regchange1.bat batch file by calling it from a logon script and watch all your servers have their IP settings changed!

This is just one simple example of how to use Regfind. There are many command-line arguments, so please examine those to meet your needs.

Leave a comment or ask a question
Total comments: 0

Microsoft OS family Disclaimer

  • The e-articles directory is not responsible for any and all copyright infringements by writers and authors. If you suspect the information contained by this page for any copyright infringements, please contact us to investigate the issue
Top Five Tools in Windows 2000 - Here's one IT professional's take on five third-party tools for Windows 2000 every system administrator should have. There can be no doubt that with every release of Microsoft's opera (more...)
Designing Active Directory for Exchange Server 2007 - Active Directory (AD) is a necessary and fundamental component of any Exchange 2007 implementation. That said, organizations do not necessarily need to panic about setting up Active Directory in (more...)
Delegate Control of an OU to a User - Rather than use the Delegation of Control Wizard, use this script to delegate authority over an organizational unit (OU) to a particular user. By delegating administrative responsibilit (more...)
Automatically Windows Log On After Booting - It's sometimes convenient to configure machines to log on automatically when booted. Here are three ways to do this. In all versions of Windows that are based on Windows NT (including W (more...)
Bit Mapped Graphics - Windows marked the transition of the primary operating mode of PC display systems. From character-based displays, Windows ushered in the age of the bit-mapped display. Bit-mapped graphics (more...)
The Evolution of Microsoft Windows ~ Windows XP 64 bit Editions - The CPU story is not over, however. The need for processors capable of handling far more than 4GB of memory has led to development of two competing 64-bit architectures. Intel developed and pro (more...)
MS DOS Alternatives - IBM and several other PC manufacturers all sold customized versions of Microsoft's MS-DOS, and that there was a competitor called DR-DOS. Gary Kildall, whom we left several pages ago sp (more...)
DOS Extenders - A few powerful DOS programs broke the normal DOS rules and were able to leap into protected mode and take advantage of its vast addressing range. They are able to stretch into extended memory us (more...)
SharePoint - The recent adoption of the web and web-related technologies makes portal technologies an obvious choice. Because portal technologies are web-based, decision makers can access important informatio (more...)
Printing from DOS Applications - If you are still using MS-DOS applications, printing is one of the more problematic areas. Many modern inexpensive inkjet and laser printers don’t support output from DOS programs beca (more...)

 
free content
    Copyright © 2006 - 2012 e-articles.info.
The texts, articles and tutorials in the directory are property of their respective owners and authors.