Scripting the deletion of registry keys and values

This content is 20 years old. I don't routinely update old blog posts as they are only intended to represent a view at a particular point in time. Please be warned that the information here may be out of date.

One of my colleagues (who wishes to remain anonymous) gave me a great tip this morning – how to delete registry keys and values using a .REG file.

To delete a value, set its contents to – in the .REG file, e.g.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\MyKey]
"MyValue"=-

Or to delete a key, add a – sign after the leading [ in the .REG file, e.g. [-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\MyKey]

Apparently this works on all version of Windows from Windows 2000 onwards, although I’ve only tried it with Windows XP Professional.

One thought on “Scripting the deletion of registry keys and values

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.