How to add a registry key using the command line

Use the REG ADD to add a subkey or entry to the registry


reg add <KeyName> [{/v ValueName | /ve}] [/t DataType] [/s Separator] [/d Data] [/f]

Specifies the full path of the subkey or entry to be added. To specify a remote computer, include the computer name (in the format \\<ComputerName>\) as part of the KeyName. Omitting \\ComputerName\ causes the operation to default to the local computer. The KeyName must include a valid root key. Valid root keys for the local computer are: HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are: HKLM and HKU.
/v <ValueName>
Specifies the name of the registry entry to be added under the specified subkey.
Specifies that the registry entry that is added to the registry has a null value.
/t <Type>
Specifies the type for the registry entry. Type must be one of the following:
/s <Separator>
Specifies the character to be used to separate multiple instances of data when the REG_MULTI_SZ data type is specified and more than one entry needs to be listed. If not specified, the default separator is \0.
/d <Data>
Specifies the data for the new registry entry.
Adds the registry entry without prompting for confirmation.
Displays help for reg add at the command prompt.

REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop /t REG_EXPAND_SZ /d "%directory%:\Documents and Settings\%UID%\Desktop" /f
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Favorites /t REG_EXPAND_SZ /d "%directory%:\Documents and Settings\%UID%\Favorites" /f
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal /t REG_EXPAND_SZ /d "%directory%:\Documents and Settings\%UID%\My Documents" /f
Share on Google Plus

About Tom DeMeulenaere

Highly accomplished information technology professional with extensive knowledge in System Center Configuration Manager, Windows Server, SharePoint, and Office 365.
    Blogger Comment