RegDelete

AutoHotkey

RegDelete

Deletes a subkey or value from the registry.

RegDelete, RootKey\SubKey [, ValueName]  ; Requires [v1.1.21+]
RegDelete, RootKey, SubKey [, ValueName]

Parameters

RootKey

Must be either HKEY_LOCAL_MACHINE, HKEY_USERS, HKEY_CURRENT_USER, HKEY_CLASSES_ROOT, or HKEY_CURRENT_CONFIG (or the abbreviations for each of these, such as HKLM). To access a remote registry, prepend the computer name and a colon (or [in v1.1.21+] a slash), as in this example: \\workstation01:HKEY_LOCAL_MACHINE

SubKey

The name of the subkey (e.g. Software\SomeApplication).

RootKey\SubKey [v1.1.21+]

If RootKey is followed immediately by a slash (\), RootKey and SubKey are merged into a single parameter.

ValueName

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

ErrorLevel

[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 potential 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.

Related

RegRead, RegWrite, Registry-loop, SetRegView, IniDelete

Example

RegDelete, HKEY_LOCAL_MACHINE, Software\SomeApplication, TestValue
RegDelete, HKEY_LOCAL_MACHINE\Software\SomeApplication, TestValue  ; Requires [v1.1.21+]