Erase-a-RegKey.

For many years now I've been using .REG files to deploy registry changes - quick, easy and notepad-compatible. The problem is that I could easily add or modify keys with this, but couldn't erase them - there was no notation in the REG file format to erase a key or value - or at least none that I know of...

I don't know which version of Windows first started supporting it, but on Win2000 it works like a charm - when specifying the name of the key, simply add a Minus sign in the beginning, and the key will be wiped clean without a trace.

I don't know if it's possible to erase a value inside a key, too - never tried it. But it wipes a key with all sub-keys and values easily.

Ex:

This creates a key:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\Software\MyStuff]
"MyLittleValue"=dword:00000001

And this erases it!

Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\Software\MyStuff]
"MyLittleValue"=dword:00000001 (This line is meaningless when erasing a key).

2 Comments

  • AT said

    Your code will delete entire HKEY_LOCAL_MACHINE\Software\MyStuff key.

    MyLittleValue line has no any effect in erase file example.


    If you need to delete single or multiple values instead of key use:

    Delete values:

    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\Software\MyStuff]
    "MyLittleValue"=-
    "MyLittleValue2"=-

    But if you still need to delete entire key

    Windows Registry Editor Version 5.00
    [-HKEY_LOCAL_MACHINE\Software\MyStuff]

Comments have been disabled for this content.