|

How To Use The Reg Add Command In Windows (2026)

The reg add command creates a registry key or sets a registry value from Command Prompt, with no Registry Editor window needed.

The basic form is reg add /v /t /d /f.

This guide follows Microsoft’s reg add and reg reference pages, so every switch below is documented.

Table of Contents

Reg add quick answers

I want toType this
Create a keyreg add HKCU\Software\MyCo
Set a number valuereg add HKCU\Software\MyCo /v Level /t REG_DWORD /d 1 /f
Set a text valuereg add HKCU\Software\MyCo /v Name /t REG_SZ /d Demo /f
Set the default (unnamed) valuereg add HKCU\Software\MyCo /ve /d Demo /f
Back up a key firstreg export HKCU\Software\MyCo C:\backup\MyCo.reg

The MyCo key and the values here are placeholders, so swap in the real path from your instructions.

Back up the registry before you change it

Microsoft cautions that you should not edit the registry directly unless you have no alternative.

It says the registry editor bypasses standard safeguards, so incorrect settings can degrade performance, damage the system, or require reinstalling Windows.

Where possible, Microsoft recommends Control Panel or MMC programs instead, and a backup if you must edit directly.

Open Command Prompt

  1. Press the Windows key and type cmd.
  2. Right-click Command Prompt and choose Run as administrator.
  3. Type your reg add command and press Enter.

The steps for an elevated window are in how to open Terminal as administrator.

The reg add syntax

Microsoft gives the syntax as reg add [/v valuename | /ve] [/t datatype] [/s separator] [/d data] [/f] [/reg:32 | /reg:64].

The keyname is the full path and must start with a valid root key.

If the key name contains a space, enclose it in quotes.

Registry root keys you can use

Short nameFull name
HKCRHKEY_CLASSES_ROOT
HKCUHKEY_CURRENT_USER
HKLMHKEY_LOCAL_MACHINE
HKUHKEY_USERS
HKCCHKEY_CURRENT_CONFIG

For a remote computer, put \\computername\ in front of the key name, and only HKLM and HKU are valid roots there.

Reg add switches at a glance

SwitchWhat it does
/v Names the registry entry to add.
/veAdds an entry with a null value.
/t Sets the data type of the entry.
/s Sets the character that separates items in a REG_MULTI_SZ value, and the default separator is \0.
/d Sets the data for the new entry.
/fAdds the entry without asking for confirmation.
/reg:32 or /reg:64Accesses the key through the 32-bit or the 64-bit registry view.

Data types for the /t switch

Microsoft lists nine accepted types.

  • REG_SZ, REG_MULTI_SZ and REG_EXPAND_SZ for text
  • REG_DWORD, REG_DWORD_LITTLE_ENDIAN and REG_DWORD_BIG_ENDIAN for numbers
  • REG_BINARY, REG_LINK and REG_FULL_RESOURCE_DESCRIPTOR for the rest

Add a value step by step

  1. Decide the full key path, the value name, the type and the data from the instructions you are following.
  2. Export the key first with reg export .reg so you can undo the change.
  3. Run reg add /v /t /d .
  4. Answer the overwrite prompt, or add /f to skip it.
  5. Check the result with reg query /v .

Microsoft documents reg export as a local-only operation that writes a file with a .reg extension, and /y overwrites an existing file without asking.

Examples from Microsoft

GoalCommand
Add a key on remote computer ABCreg add \\ABC\HKLM\Software\MyCo
Add a REG_BINARY value named Datareg add HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead
Add a REG_MULTI_SZ value named MRUreg add HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail\0
Add a REG_EXPAND_SZ value named Pathreg add HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d ^%systemroot^%

For a REG_EXPAND_SZ value, Microsoft says to use the caret symbol with each percent sign inside the data.

Check whether the command worked

The command returns 0 for success and 1 for failure.

Microsoft also notes that this version of reg does not ask for confirmation when adding a subkey, and that subtrees cannot be added with this operation.

Choose the 32-bit or 64-bit registry view

On a 64-bit system the same key path can exist in two views, and the /reg:32 and /reg:64 switches pick which one the command touches.

Use /reg:64 when you want the 64-bit view and /reg:32 when the software you are configuring is 32-bit.

If you leave both out, reg uses its default view, so name one whenever the instructions tell you to.

Look up a value with reg query before you add it

Running reg query on the key first shows whether the value already exists and what it holds.

SwitchWhat it does in reg query
/v Returns only that value.
/veQueries for value names that are empty.
/sQueries all subkeys and value names recursively.
/f Searches for the data or pattern given.
/k or /dSearches key names only, or data only.
/c and /eMake the search case sensitive, or return exact matches only.

Microsoft’s example reg query HKLM\Software\Microsoft\ResKit /v Version shows the form to copy for a single value.

Add a REG_MULTI_SZ value with a separator

A REG_MULTI_SZ value holds several strings, and the /s switch sets the character that separates them in your /d data.

If you do not give a separator, Microsoft says the default is \0, as in the fax\0mail\0 example above.

Mistakes that stop a reg add command

  • Leaving out the root key, because Microsoft says the key name must include a valid one such as HKCU or HKLM.
  • Forgetting quotes around a key path that contains a space.
  • Typing %systemroot% without carets in a REG_EXPAND_SZ value, so the percent signs are not kept as text.
  • Using a root other than HKLM or HKU on a remote computer.
  • Adding /f before you have checked the path, which hides the overwrite prompt.

If the command prints an error and returns 1, fix the path or the type and run it again.

CommandWhat it does
reg queryLists the subkeys and entries under a key, and /s searches recursively.
reg exportCopies a key into a .reg file.
reg importCopies the contents of an exported file back into the registry.
reg deleteDeletes a subkey or entries, and /f skips the prompt.
reg save and reg restoreSave subkeys to a file and write them back later.

Undo a change

To put a key back, run reg import .reg with the file you exported earlier.

To remove a value you added, run reg delete /v .

Microsoft says that reg delete with no value named removes all entries and subkeys under the subkey, so check the path twice.

Related guides

Other Windows commands are covered in the Robocopy guide, the Gpupdate guide and the Net User guide.

Official sources

The syntax, switches and examples come from Microsoft’s reg add reference.

The warning and subcommand list come from the reg reference, with the related commands documented on its reg query, reg export and reg delete pages.

Leave a Reply

Your email address will not be published. Required fields are marked *