Deleting and Renaming Registry Keys and Values with a .reg file

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_MACHINESoftware

put a hyphen in front of the following registry key in the .reg file:

HKEY_LOCAL_MACHINESoftwareTest

The following example has a .reg file that can perform this task.

[-HKEY_LOCAL_MACHINESoftwareTest]

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_MACHINESoftwareTest

put a hyphen after the "TestValue"= in the .reg file. The following example has a .reg file that can perform this task.

HKEY_LOCAL_MACHINESoftwareTest
"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.

 

Reference: How to add, modify, or delete registry subkeys and values by using a registration entries (.reg) file

Leave a Reply

Your email address will not be published. Required fields are marked *