Skip navigation

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


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_MACHINE\SYSTEM\CurrentControlSet\Services\Stuff\]
"GuessWhat"="????"

\[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Stuff\More\]
"HostName"="NameHost"

\[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ZipZap\]
"GuessWhat"="????"

\[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ZipZap\Zip\]
"ZipZap"="ZapZip"
\[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ZipZap\Zap\]
"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_MACHINE\SYSTEM\CurrentControlSet\Services\Stuff\]

\[-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\ZipZap\Zip\]
If the file name was c:\regdel.reg, then:

regedit /s c:\regdel.reg

where the optional /s makes it silent.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish