Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


April 2001

Distributing Registry Changes


RSS
Subscribe to Windows IT Pro | See More Registry Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!
SideBar    A Registration File Drawback, Registry Data Types, Make the Connection

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
   Previous  1  [2]  3  4  5  6  Next 


Reader Comments
<br>In "Distributing Registry Changes" (April 2001), Kathy Ivens states, "Registration (.reg) files can't delete anything in the registry." They can! I use .reg files to customize my desktop at startup, and one of the registry subkeys I delete is HKEY_CURRENT_
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


<br><i>You're correct, and several readers pointed out the error. In fact, deleting keys and items with a .reg file is dangerously easy. Putting a hyphen at the beginning of the registry path deletes the key. To delete an individual data item in a registry key, use this format in the .reg file.<br><br>
&lt;RegistryEditorVersion&gt;<br><br>

[&lt;RegistryPath&gt;] <br>
"&lt;DataItemName&gt;"=- <br><br>

The best way to proceed is to use regedit to export the key, then edit the .reg file and insert the appropriate hyphens. Use Save As, and apply a new filename to this revised .reg file. That way, you can make sure the original values are still available in case you do something wrong or change your mind. Just double-click your new .reg file to merge its contents into the registry.</i><br>
<i>--Kathy Ivens</i>

Kathy Ivens June 19, 2001


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

New Microsoft/Yahoo! Deal? No

On Sunday, the Times of London reported that Microsoft had renewed talks with failing Internet giant Yahoo! and would manage its search engine for 10 years, while Yahoo! would retain control of its email, messaging, and content services. This report ...

How can I stop and start services from the command line?

...


Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing