10 June 2011

Adding and Changing Registry Values


To add a registry subkey or add or change a registry value, make the appropriate changes in the registry, and then export the appropriate subkey or subkeys. Exported registry subkeys are automatically saved as .reg files. To make changes to the registry and export your changes to a .reg file, follow these steps:
  1. Click Start, click Run, type regedit in the Open box, and then click OK.
  2. Locate and then click the subkey that holds the registry item or items that you want to change.
  3. Click File, and then click Export.

    This step backs up the subkey before you make any changes. You can import this file back into the registry later if your changes cause a problem.
  4. In the File name box, type a file name to use to save the .reg file with the original registry items, and then click Save.

    Note Use a file name that reminds you of the contents, such as a reference to the name of the subkey.
  5. In the right pane, add or modify the registry items you want.
  6. Repeat steps 3 and 4 to export the subkey again, but use a different file name for the .reg file. You can use this .reg file to make your registry changes on another computer.
  7. Test your changes on the local computer. If they cause a problem, double-click the file that holds the backup of the original registry data to return the registry to its original state. If the changes work as expected, you can distribute the .reg you created in step 6 to other computers by using the methods in the "Distributing Registry Changes" section of this article.

Deleting Registry Keys and Values
To delete a registry key with a .reg file, put a hyphen (-) in front of the RegistryPath in the .reg file. For example, to delete the Test subkey from the following registry key:
HKEY_LOCAL_MACHINE\Software
put a hyphen in front of the following registry key in the .reg file:
HKEY_LOCAL_MACHINE\Software\Test
The following example has a .reg file that can perform this task.
[-HKEY_LOCAL_MACHINE\Software\Test]
To delete a registry value with a .reg file, put a hyphen (-) after the equals sign following the DataItemName in the .reg file. For example, to delete the TestValue registry value from the following registry key:
HKEY_LOCAL_MACHINE\Software\Test
put a hyphen after the "TestValue"= in the .reg file. The following example has a .reg file that can perform this task.
HKEY_LOCAL_MACHINE\Software\Test
"TestValue"=-
To create the .reg file, use Regedit.exe to export the registry key that you want to delete, and then use Notepad to edit the .reg file and insert the hyphen.

Renaming Registry Keys and Values
To rename a key or value, delete the key or value, and then create a new key or value with the new name.

Distributing Registry Changes
You can send a .reg file to users in an e-mail message, put a .reg file on a network share and direct users to the network share to run it, or you can add a command to the users' logon scripts to automatically import the .reg file when they log on. When users run the .reg file, they receive the following messages:
Registry Editor
Are you sure you want to add the information in path of .reg file to the registry?
If the user clicks Yes, the user receives the following message:
Registry Editor
Information in path of .reg file has been successfully entered into the registry.
Regedit.exe supports a /s command-line switch to not display these messages. For example, to silently run the .reg file (with the /s switch) from a login script batch file, use the following syntax:
regedit.exe /s path of .reg file

No comments:

Post a Comment