Search code examples
regedit

I want to add a key directory directly under HKEY_CLASSES_ROOT with batch command (as like a subfolder)


I want to add a key folder (..NewKey) directly under HKEY_CLASSES_ROOT with batch command (as like a subfolder, on the left side), and then add several keys into this key folder. If i try to do it manualy, and right click HKEY_CLASSES_ROOT i can do this with add key (see picture1) If i try it with reg add command like below, the key is generated directly in HKEY_CLASSES_ROOT (see picture2) What am i doing wrong?

reg add "HKEY_CLASSES_ROOT" /v ..NewKey /t REG_SZ /d Server

picture1

enter image description here


Solution

  • You need to specify the new key name as part of the KeyName parameter, then speecify /ve. This creates the key with an empty (Default) value. Optionally, add the /t and /d parameters with approproate values to create the key with a non-empty (Default) value.

    reg add "hkcr\...NewKey" /ve
    

    or

    reg add "hkcr\...NewKey" /ve /t REG_SZ /d "Server"
    

    REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f] [/reg:32 | /reg:64]

    KeyName [\Machine]FullKey Machine Name of remote machine - omitting defaults to the current machine. Only HKLM and HKU are available on remote machines. FullKey ROOTKEY\SubKey ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ] SubKey The full name of a registry key under the selected ROOTKEY.

    /v The value name, under the selected Key, to add.

    /ve adds an empty value name (Default) for the key.

    /t RegKey data types [ REG_SZ | REG_MULTI_SZ | REG_EXPAND_SZ | REG_DWORD | REG_QWORD | REG_BINARY | REG_NONE ] If omitted, REG_SZ is assumed.

    /s Specify one character that you use as the separator in your data string for REG_MULTI_SZ. If omitted, use "\0" as the separator.

    /d The data to assign to the registry ValueName being added.

    /f Force overwriting the existing registry entry without prompt.