Tips from the Windows Pros: Deploying Registry Settings with REG Files


If you find yourself having to make the same registry settings on a whole department's or company's worth of computers, or if you frequently reinstall Windows and have to reapply the same settings every time you reload, you should know this neat way of setting a bunch of registry entries with just a mouse-click or two.

We discussed REG files earlier in this chapter as a way of backing up and restoring the registry. You can also use REG files to automatically deploy (that is, distribute and install) a set of identical registry settings to several computers. For example, I've used this technique to quickly copy a complicated set of file associations in the HKEY_CLASSES_ROOT registry section to all of the computers in a client's office.

The trick here is to export the relevant registry keys and values using regedit's Export feature, as described earlier in the chapter. Trim down the resulting REG files with Notepad so that they contain only the exact entries that you need to copy. Then, using cut and paste, put them all into one file. The first line should contain Windows Registry Editor Version 5.00, and this should be followed by key names, with any necessary values under the keys.

REG files can also delete registry keys or values. To delete a value, specify a single minus sign (-) after the value's equals sign. To delete a key (and all subkeys and values under it), precede the key name with a minus sign. For example, the following REG file deletes a value named GoodbyeValue and the key named HKEY_CURRENT_USER\Software\GoodbyeKey.

 Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Some key or another] "GoodbyeValue"=- [-HKEY_CURRENT_USER\Software\GoodbyeKey] 

These entries can be mixed in with other REG entries that set keys. For instance, you might want to delete a given keythus removing any extraneous subkeys and valuesbefore you install a clean, new version:

 Windows Registry Editor Version 5.00 [-HKEY_CURRENT_USER\Software\MyKey] [HKEY_CURRENT_USER\Software\MyKey] @="Standard default Value" value1="standard value1 setting" value2="standard value2 setting" 

Here's an example of how this all works. The following REG file deletes any previous associations for the file extensions .sgm and sgml, and creates an association for both to open with application sgmledit.exe.

 Windows Registry Editor Version 5.00 [-HKEY_CLASSES_ROOT\.sgm] [-HKEY_CLASSES_ROOT\.sgml] [-HKEY_CLASSES_ROOT\SGML File] [HKEY_CLASSES_ROOT\.sgm] @="SGML File" [HKEY_CLASSES_ROOT\.sgml] @="SGML File" [HKEY_CLASSES_ROOT\SGML File\shell\open\command] @="\"c:\\program files\\SGMLEdit\\sgmledit.exe\" \"%1\"" 

To deploy the registry settings to a given computer, double-click the REG file in an Explorer window, or type into a Command Prompt window the command

 regedit filename.reg 

replacing filename.reg with the name of your REG file. You might need to specify the file's full path, if you're carrying it around on a floppy disk or have it stored on a network shared folder. In some circumstances, you might want to reset some registry values every time a user logs on. You can do this by running the regedit command from a logon script. In this case, you don't want the users to have to confront a dialog box asking them to confirm importing the values. You can silently install a Registry file from the command line using the following command format:

 regedit /s filename.reg 



Special Edition Using Microsoft Windows XP Professional
Special Edition Using Microsoft Windows XP Professional (3rd Edition)
ISBN: 0789732807
EAN: 2147483647
Year: 2003
Pages: 450

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net