Reference/DeleteRegKey: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Created page with "=DeleteRegKey= [/ifempty] root_key subkey Deletes a registry key. If /ifempty is specified, the registry key will only be deleted if it has no subkeys (otherwise, the whole re...")
 
 
Line 5: Line 5:
Deletes a registry key. If /ifempty is specified, the registry key will only be deleted if it has no subkeys (otherwise, the whole registry tree will be removed). Valid values for root_key are listed under [[Reference/WriteRegStr|WriteRegStr]]. The error flag is set if the key could not be removed from the registry (or if it didn't exist to begin with).
Deletes a registry key. If /ifempty is specified, the registry key will only be deleted if it has no subkeys (otherwise, the whole registry tree will be removed). Valid values for root_key are listed under [[Reference/WriteRegStr|WriteRegStr]]. The error flag is set if the key could not be removed from the registry (or if it didn't exist to begin with).


<highlight-nsis>DeleteRegKey HKLM "Software\My Company\My Software"
<highlight-nsis>DeleteRegKey HKLM "Software\My Company\My Software\"
DeleteRegKey /ifempty HKLM "Software\A key that might have subkeys"</highlight-nsis>
DeleteRegKey /ifempty HKLM "Software\A key that might have subkeys\"</highlight-nsis>
 
The registry key must end with a backslash in the ''DeleteRegKey'' call. Otherwise the registry key cannot be removed.

Latest revision as of 12:23, 8 September 2025

DeleteRegKey

[/ifempty] root_key subkey

Deletes a registry key. If /ifempty is specified, the registry key will only be deleted if it has no subkeys (otherwise, the whole registry tree will be removed). Valid values for root_key are listed under WriteRegStr. The error flag is set if the key could not be removed from the registry (or if it didn't exist to begin with).

DeleteRegKey HKLM "Software\My Company\My Software\"
DeleteRegKey /ifempty HKLM "Software\A key that might have subkeys\"

The registry key must end with a backslash in the DeleteRegKey call. Otherwise the registry key cannot be removed.