Windows NT Professional
May 1999

Automating Registry Changes

As you probably know, the Windows NT Registry is a database that stores all information about your computer's configuration--including hardware, software, and user information. Every modification or change you make to the Windows NT environment alters the Registry in some way.

Windows NT provides some tools that allows indirect changes to the Registry without the risk of disastrous side effects, such as Control Panel and System Policy Editor. Although these tools should be used whenever possible, there are many Windows NT configuration changes that require you to directly edit the Registry. As a network administrator, you can go crazy trying to make Registry changes to all or some of your workstations. In this article, we'll show you how to simplify and expedite the task through the use of a Registry patch.

Explaining Registry patches

A Registry patch is a simple text file with a REG extension that can be edited in any text editor, such as Notepad. This text file contains one or more Registry keys or values, depending upon what you've exported from the Registry. Windows NT recognizes this simple-text file as a valid Registry patch, not only by the REG extension, but also by the REGEDIT4 line that appears in the first line of the file. It's very important that you make no changes to this line when modifying the Registry file, so that once you make your changes to the file, it can be merged with the contents of the Registry for your changes to take effect.

Creating a Registry patch

Creating a Registry patch is a simple process. For example, let's use a Registry patch to create a custom logon message that can be dispersed to all workstations. To begin, launch the Registry Editor by clicking Start/Run and typing Regedit in the Open dropdown list box. (You must use Regedit and not Regedt32 for this procedure.) Navigate to the HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon subkey. For this procedure, we'll edit both the LegalNoticeCaption and LegalNoticeText values in the right-hand pane. As you can see in Figure A, there currently is no value for either entry. We'll use the Registry patch to change these values so that the message shown in Figure B appears when a user logs on to their workstation.

Figure A: We'll change the value in the right-hand pane of the Registry Editor.
 Figure A

Figure B: You can use a Registry patch to create a message that appears when the user logs on.
 Figure B

Once you've navigated to the correct subkey, select Export Registry File from the Registry menu. As Figure C shows, the Selected Branch option in the Export Range panel should be selected, and the branch should appear correctly in the text box. If you're using the Registry patch right away, you can save it to your desktop for easy access. Type Legal in the File Name text box and click the Save button. You should now have an icon named Legal on your desktop.

Figure C: The Export Registry File function allows you to save a selected branch of your Windows NT Registry.
 Figure C

Editing the Registry patch

Now that you've successfully created the Registry patch, edit it to incorporate the desired changes. However, before making any changes to the patch, we recommend making a copy of it that can be used as a backup in case you need to restore the original values. To do so, simply right-click on the Legalicon and select Copy from the shortcut menu. Next, right-click on an empty area of the desktop and select Paste from the shortcut menu. You now have an icon named Copy Of Legal on your desktop.

To begin editing the Registry patch, right-click on the Legal icon and select Edit from the shortcut menu. Since the patch is a simple text file, Notepad opens as the default editor. As Figure D shows, the first line of the file is the REGEDIT4 line we referred to earlier that allows Windows NT to recognize this file as a Registry patch. The second line of text that appears in brackets is the Registry key that you exported. On the lines below the full key path are all the values of the key. Since you're working strictly with the LegalNoticeCaption and LegalNoticeText values, you can delete all other values from the file. Therefore, only the values that remain will be affected when the Registry patch is merged with the Registry.

Figure D: A Registry patch is a simple-text file that can be edited in Notepad.
 Figure D

Next, type the text for each of the values in between the quotation marks, as shown in Figure E. Make sure that the second and last lines of the file remain blank. When finished, select Save from the file menu and close Notepad.

Figure E: Type the text that you want to be merged into the Windows NT Registry.
 Figure E

Applying a Registry patch

After you've created and edited your Registry patch, applying the changes is simple. To merge the values in the patch with the Windows NT Registry, either double-click on the Legal icon or right-click on it and select Merge from the shortcut menu. If your Registry patch has worked correctly, it displays the message shown in Figure F. To verify that the LegalNoticeCaption and LegalNoticeText values were set correctly, run Regedit and compare them with the values in Figure G.

Figure F: The Registry Editor displays this message after you merge the patch with the Registry.
 Figure F

Figure G: Running the Legal Registry patch changes the LegalNoticeCaption and LegalNoticeText values in your Registry.
 Figure G

To test your changes to the Registry, restart your system and wait for the message shown in Figure B to appear. If you encounter problems with your system after using the patch, double-click the backup copy of the exported branch to restore your original values. To disperse the patch to all or some of the workstations on your network, place the Registry patch on a network drive so that other users have access to it.

Caveats

Registry patches are a great way to share Registry changes with multiple users. However, when using a REG file on multiple computers, make sure that the computers have similar or identical configurations.

Also, although using Registry patches is a safer method than directly using Regedit, manually making any changes to the Registry is still a dangerous process. For this reason, we highly recommend either backing up your entire Registry, or following our procedure for making a backup copy of the selected branch before making changes. As always, you can never be too careful when working with the Registry.

Conclusion

For changes that you make to your system's configuration or environment settings that aren't integrated into Control Panel's functions, you must manually edit the Registry. Registry patches are a great way to automate these changes if you use the proper precautions.


Copyright © 1999, ZD Inc. All rights reserved. ZD Journals and the ZD Journals logo are trademarks of ZD Inc. Reproduction in whole or in part in any form or medium without express written permission of ZD Inc. is prohibited. All other product names and logos are trademarks or registered trademarks of their respective owners.