Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How do you delete registry keys by using .reg files?
What is the correct syntax for doing this?
Thanks

You cannot delete a key with a .reg file. You can only alter an existing key or add a new one. Delete your key directly from the Registry via RegEdit.

In case you didn't know, you can add, edit or delete your registry entries by using .inf files. It is also possible to copy files, among other tasks, but this is not discussed here.
This mode of registry editing is suitable for automated tasks such as installing/uninstalling software or clearing known groups of keys such as the Run history or Recent Documents history.
Try to understand and adapt the following example to your particular needs to get rid of your registry editing nightmares.
It is supposed that you know what you are doing, you are on your own on this, and have at least an idea of how the registry performs its tasks.
The example works as-is, but the explanation is incomplete on purpose to make you think twice before editing the registry this way.
But first some guidelines for the proper syntax:root-key, sub-key, [value name]
The value name is optional and is denoted by the [] brackets.
The comma place holder shown above must be included in this line.
Note that if the sub-key or Value name contains spaces you need to use quotes.
Registry entries between quotes may be case sensitive.
The value name entry allows the definition of a particular entry to be removed from a sub-key.The root-key is represented by one of the following abbreviations:
HKCR is short for HKEY_CLASSES_ROOT
HKCU is short for HKEY_CURRENT_USER
HKLM is short for HKEY_LOCAL_MACHINE
HKU is short for HKEY_USERSThe sub-key is the continuation of the path to the value to be changed, for example:
HKLM,Software\Microsoft\Windows\currentVersion\Fonts removes the Fonts Key and all of its contents.
; Example of .inf file, name it as you wish.
; Use the ';' character to add comments in your code.
; .inf files have lots of distinct options, this is only a brief working example.;This example adds and deletes the same key
[Version]
Signature="$CHICAGO$"[DefaultInstall]
AddReg = List_of_HKEYs_to_Add
DelReg = List_of_HKEYs_to_Delete[List_of_HKEYs_to_Add]
HKLM,Software\DynamoSound\0001,mondoStereo,[List_of_HKEYs_to_Delete]
HKLM,Software\DynamoSound\0001,mondoStereo,
; We hope this helps!!

You could delete keys with Reg files using this:
Look at this example...
-----------------------------------
REGEDIT4[-HKEY_CURRENT_USER\Network\Recent]
<- Remember a line in blank
-----------------------------------With this text saved as a Reg file you will delete the last Network connections make in your computer...
This is the effect of the "-" that is before the key of the Registry... It deletes the said key and their children keys... ((It's Recursive))
Sorry for my bad english, I'm spanish...
If you want something about this, please write it in this forum and send me an e-mail, I don't read this forum, sorry!!!

You could delete keys with Reg files using this:
Look at this example...-----------------------------------
REGEDIT4[-HKEY_CURRENT_USER\Network\Recent]
<- Remember a line in blank-----------------------------------
With this text saved as a Reg file you will delete the last Network connections make in your computer...
This is the effect of the "-" that is before the key of the Registry... It deletes the said key and their children keys... ((It's Recursive
How would I then delete a value within the key?
thanks,
Ethan

The examples where you place the minus in front of the command for .reg files will *not* work in 95. The inf examples work best for 95

Prefixing a registry key with a minus to delete it is great an it works well. Does anyone know how to go about handling permissions and such? I tried saving a key from regedt32 but the format is binary...?

You can also use the reg.exe utility that comes with NT4 resource kit. This webpage has the syntax:
http://www.swynk.com/trent/articles/REGSyn.asp
It works with 95 as well.

>The examples where you place the minus in front of the command for .reg files will *not* work in 95.<
My Win95b works just fine with it, maybe only earlier versions are affected...?

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |