JSI Tip 2165. How do I delete a key, using regedit in batch?

Jerold Schulman

March 19, 2000

1 Min Read
ITPro Today logo in a gray background | ITPro Today


To delete a key using Regedit, include a minus sign in front of the key path.

Assume you had the following keys and values:

[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesStuff]"GuessWhat"="????"[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesStuffMore]"HostName"="NameHost"[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesZipZap]"GuessWhat"="????"[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesZipZapZip]"ZipZap"="ZapZip"[HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesZipZapZap]"BlahBlah"="string"

If you wanted to delete the entire Stuff service and the Zip subkey of the ZipZap service, you would submit the following within a .reg file (including the proper header for your version of Regedit):

[-HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesStuff][-HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesZipZapZip]

If the file name was c:regdel.reg, then:

regedit /s c:regdel.reg

where the optional /s makes it silent.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like