Creates a registry key without writing a value.

RegCreateKey KeyName



Type: String

The full name of the registry key.

This must start with 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 slash, as in this example: \\workstation01\HKEY_LOCAL_MACHINE

KeyName can be omitted only if a registry loop is running, in which case it defaults to the key of the current loop item (even if the key has been deleted during the loop). If the item is a subkey, the full name of that subkey is used by default.

Error Handling

An OSError is thrown on failure.

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


If KeyName specifies an existing registry key, RegCreateKey verifies that the script has write access to the key, but makes no changes. Otherwise, RegCreateKey attempts to create the key (along with its ancestors, if necessary).

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

To create subkeys in the 64-bit sections of the registry in a 32-bit script or vice versa, use SetRegView.

RegDelete, RegDeleteKey, RegRead, RegWrite, Registry-loop, SetRegView


Creates an empty registry key. If Notepad++ is installed, this has the effect of adding it to the "open with" menu for .ahk files.

RegCreateKey "HKCU\Software\Classes\.ahk\OpenWithList\notepad++.exe"