Distributing Registration Files
A quick way to create a .reg file for distribution is to use regedit to export a key (or multiple keys), then use the resulting .reg file (or files). To export a key, select the key and choose Registry, Export Registry File. In the Export Registry File dialog box, enter a name and select a folder for the export file. Windows automatically adds the .reg extension. You can interactively change the registry settings on one computer, then export the key and use the export file as is, or you can export the key, then manually edit it. To edit a .reg file, don't double-click the file; instead, right-click and choose Edit from the shortcut menu. The file opens in Notepad. If you want to make registry changes in multiple keys, open each .reg file, paste the files' contents into one Notepad document, then save that document with a .reg extension.
You can distribute .reg files in any convenient manner. Attach the .reg file to an email message, add the appropriate command to a logon script, or use any other method you're comfortable with.
Users don't need to open regedit and use its Import command to bring the contents of a .reg file into the registry; they can merely double-click the .reg file from Windows Explorer or My Computer to automate the import process. (If you right-click a .reg file, you can see that the default action is Merge. However, no Merge command exists in any version of Windows; that command is a stand-in for the command
regedit.exe "%1"
in which the variable uses the current file.) For command-line execution, use the syntax
regedit <filename>.reg
Regardless of the method, the OS asks the user to confirm that he or she wants to merge data into the registry. Clicking Yes launches the merge. After the file successfully merges into the registry, the OS issues a success message. If the file has the wrong syntax and the merge fails, the OS issues an error message explaining that the file isn't a registry script and can't be imported to the registry.
If you want to execute multiple .reg files (one for each modification) instead of combining all the registry changes into one file, use a batch file that calls each .reg file. To avoid the need for user intervention, use the following syntax to run .reg files from the command line in quiet mode:
regedit /s <filename>.reg
Registration files work for Win95 and later. However, many registry subkeys and data items differ among versions, so you should create separate .reg files for each platform. Name the files appropriately so that you don't get confused (e.g., RestrictUsers9x.reg, RestrictUsersNT4.reg).
Note that even if you've used Group Policy or System Policy to disable registry-editing tools, .reg files still work. (Otherwise, software installation and other system processes couldn't manipulate the registry.)
Option 2: Get More Editing Power with Regini.exe
If scripts are your favorite tools for configuration and setup tasks, you can use regini.exe to apply your scripting skills to registry edits. Regini provides more power than .reg files can muster, including the ability to delete subkeys and data items and to set permissions on registry keys. You can find Regini in the Microsoft Windows 2000 Server Resource Kit and the Microsoft Windows NT Server 4.0 Resource Kit. (I've successfully used the Win2K version of regini.exe on NT machines, and vice versa.) The resource kits also contain full documentation (i.e., regini.doc) for this nifty utility. Regini uses the following syntax:
regini <ScriptFileName>
where ScriptFileName is the path to a script file you've written to perform a specific registry edit. You can use Uniform Naming Convention (UNC) in the path statement if the script is on a network share.
To distribute registry changes that use Regini, you must make the program available to each target computer (assuming that you haven't installed the resource kits across your enterprise). You can use a batch file to map Regini's UNC path and then run the program. For example, if Regini resides on a network share named ResKit on a server named Tools1, you can create the following batch file:
Net use x: \\tools1\reskit
x:\ regini <ScriptFileName>
Net use x: /delete
USER\Software\Microsoft\WindowsCurrentVersion\Explorer\MenuOrder. Deleting this key makes the contents of my Favorites and Start Menu folders appear in alphabetical order. In the .reg file, I simply insert a hyphen (-) inside the brackets that enclose the registry path to the subkey that I want to delete. However, I'm not sure how to use .reg files to delete individual registry values. I usually just delete the entire key and reimport the values I want.<br>
Patrick S. Seymour June 19, 2001