RegDelete

Deletes a subkey or value from the registry.

New Syntax [v1.1.21+]

RegDelete, KeyName , ValueName

Parameters

KeyName

The full name of the registry key, e.g. HKLM\Software\SomeApplication.

This must start with HKEY_LOCAL_MACHINE (or HKLM), HKEY_USERS (or HKU), HKEY_CURRENT_USER (or HKCU), HKEY_CLASSES_ROOT (or HKCR), or HKEY_CURRENT_CONFIG (or HKCC).

To access a remote registry, prepend the computer name and a colon (or in [v1.1.21+] a backslash), e.g. \\workstation01\HKLM.

ValueName

If blank or omitted, the entire KeyName will be deleted. Otherwise, specify the name of the value to delete. To delete KeyName's default value -- which is the value displayed as "(Default)" by RegEdit -- specify AHK_DEFAULT for this parameter.

Old Syntax

Deprecated: This syntax is not recommended for use in new scripts. Use the new syntax described above instead.

RegDelete, RootKey, SubKey , ValueName

Parameters

RootKey

Must be either HKEY_LOCAL_MACHINE (or HKLM), HKEY_USERS (or HKU), HKEY_CURRENT_USER (or HKCU), HKEY_CLASSES_ROOT (or HKCR), or HKEY_CURRENT_CONFIG (or HKCC).

To access a remote registry, prepend the computer name and a colon (or in [v1.1.21+] a backslash), e.g. \\workstation01\HKLM.

SubKey

The name of the subkey, e.g. Software\SomeApplication.

ValueName

If blank or omitted, the entire SubKey will be deleted. Otherwise, specify the name of the value to delete. To delete SubKey's default value -- which is the value displayed as "(Default)" by RegEdit -- specify AHK_DEFAULT for this parameter.

Error Handling

[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.

ErrorLevel is set to 1 if there was a problem or 0 otherwise.

A_LastError is set to the result of the operating system's GetLastError() function.

Remarks

Warning: Deleting from the registry is potentially dangerous - please exercise caution!

To retrieve and operate upon multiple registry keys or values, consider using a registry loop.

For details about how to access the registry of a remote computer, see the remarks in registry loop.

To delete entries from the 64-bit sections of the registry in a 32-bit script or vice versa, use SetRegView.

RegRead, RegWrite, registry loop, SetRegView, IniDelete

Examples

New syntax vs. old syntax.

Despite the different syntax, both examples have the same effect: They delete a value from the registry.

RegDelete, HKEY_LOCAL_MACHINE\Software\SomeApplication, TestValue
RegDelete, HKEY_LOCAL_MACHINE, Software\SomeApplication, TestValue