Microsoft Windows 10 Logo

Windows and a lot of third-party apps store settings in the registry. If you’re wanting to edit the registry, there are a few ways you can do it. Here’s how to edit the Windows registry from the Command Prompt.

Before we get started, it’s important that you back up the registry, as well as your computer, before you make any edits. One wrong move can make your system unstable or even completely inoperable. You can also create a System Restore point to quickly roll back your system if something goes wrong.

RELATED: The 10 Best Registry Hacks for Windows 10

Microsoft themselves publicly state that adding, modifying, or deleting Windows registry subkeys and values should only be done by advanced users, admins, and IT professionals. Take caution before you make changes.

Edit the Windows Registry from the Command Prompt

There’s a long list of reg operations. We’ll give a couple of examples of how to execute basic operations. If you’re interested in the full list of operations, each syntax, and what the parameters within each syntax represents, check out the list at the bottom of the article.

Once you’re ready to edit the Windows Registry, open the Command Prompt as an administrator.

Open the Command Prompt as Admin

To open the Command Prompt as an admin, type “cmd” in the Windows search bar.

search cmd in windows search bar


Next, right-click the “Command Prompt” app in the search results, and select “Run As Administrator” from the menu.

Command Prompt app in windows search

Command Prompt will now open in admin mode, and we can begin editing the Windows registry.

Learn the Operation Types

We’ll give a full list of the reg commands and each respective syntax later. For now, you can get a list of the operation types, as well as additional help with each operation, from the Command Prompt.

RELATED: Windows Registry Demystified: What You Can Do With It

To get the list of operations, run this command:

REG /?

The Operation List will appear, as well as the Return Code for each command.

Command to get list of operations

Here’s the list of operations and what each does, as described by Microsoft:

  • Add: Adds a new subkey or entry to the registry.
  • Compare: Compares specified registry subkeys or entries.
  • Copy: Copies a registry entry to a specified location on a local or remote machine.
  • Delete: Deletes a subkey or entries.
  • Export: Copies the specified subkeys, entries, and values of the local computer into a file for transfer to other servers.
  • Import: Copies the contents of a file that contains exported registry subkeys, entries, and values into the registry of the local computer.
  • Load: Writes saved subkeys and entries into a different subkey in the registry. This is intended to be used with temp files that are used for troubleshooting or editing registry entries.
  • Query: Returns a list of the next tier of subkeys and entries that are located und a specified subkey in the registry.
  • Restore: Writes saved subkeys and entries back to the registry.
  • Save: Saves a copy of specified subkeys, entries, and values of the registry in a specified file.
  • Unload: Removes a section of the registry that was loaded using the REG LOAD  operation.

And, the return codes:

  • 0: Successful
  • 1: Failed

To get help for with a specific operation, append the operation name to the middle of the previous command:

REG <Operation> /?

So, if I wanted help on the “Add” operation, I would run:


Run command to get help on a specific operation

As you can see, all of the information that you need about the specified operation is returned, including the syntax, parameters, and even some examples.

Now that we know all that we need to know about REG ADD , let’s try to put it in action.

Add a SubKey or Entry to the Registry

First things first, here’s the syntax for REG ADD that we retrieved from using the REG ADD /? command:

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

The <KeyName> specifies the full path of the subkey. Valid root keys for the local computer are HKLM, HKCU, HKCR, HKU, and HKCC. You can use the HKLM and HKU root keys for remote computers. /v <ValueName> specifies the name of the registry entry to be added under the specified subkey. We’ll define the rest of the parameters later, but for this example, this is all we’ll need.


So, let’s say we want to add a subkey named HowToGeekSubkey under HKEY_LOCAL_MACHINE\Software. We’ll run the following command:

REG ADD HKLM\Software\HowToGeekSubkey

If the operation was successfully executed, the Command Prompt will let you know.

command for adding a subkey to the registry

If you want to double-check that the operation was successful, you can look for yourself using the Registry Editor.

Open the Registry Editor by typing “regedit” in the Windows search bar and selecting the Registry Editor app.

open registry editor

Navigate to the location of the newly added subkey. In our case: HKEY_LOCAL_MACHINE > SOFTWARE > HowToGeekSubkey.

How to geek subkey in registry

Now that we’ve confirmed it’s there, let’s delete it.

Delete a Subkey or Entry from the Registry

Here’s the syntax for the REG DELETE operation:

REG DELETE <KeyName> [{/v ValueName | /ve | /va}] [/f]

The parameters that we care about for now are the same as before. That is, <KeyName> and /v valuename.


If we want to delete the HowToGeekSubkey subkey from HKEY_LOCAL_MACHINE\Software that we just created, we will run this command:

REG DELETE HKLM\Software\HowToGeekSubkey

This time, you’ll be asked if you really want to delete the subkey. Type Yes and press “Enter.”

Again, the Command Prompt will let you know if the operation was executed successfully.

Delete subkey from registry

You can cross-verify that the subkey was actually deleted from the Registry Editor. Navigate to the location that the subkey used to live and see if it was removed.

REG Operations, Syntax, and Parameter Descriptions

Though we only covered two simple examples, there’s a decent-sized list of REG operations. Each operation can have a potentially complex syntax. For easy access, we’ll list out all the details provided by Microsoft here.

Operation and Syntax

Operation Syntax
Add REG ADD <KeyName> [{/v ValueName | /ve}] [/t DataType] [/s Separator] [/d Data] [/f]
Compare REG COMPARE <KeyName1> <KeyName2> [{/v ValueName | /ve}] [{/oa | /od | /os | on}] [/s]
Copy REG COPY <KeyName1> <KeyName2> [/s] [/f]
Delete REG DELETE <KeyName> [{/v ValueName | /ve | /va}] [/f]

REG EXPORT KeyName FileName [/y]

Import REG IMPORT FileName

REG LOAD KeyName FileName


REG QUERY <KeyName> [{/v <ValueName> | /ve}] [/s] [/se <Separator>] [/f <Data>] [{/k | /d}] [/c] [/e] [/t <Type>] [/z]


REG RESTORE <KeyName> <FileName>


REG SAVE <KeyName> <FileName> [/y]



Parameter and Parameter Description

Parameter Description
<KeyName> 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. If the registry key name contains a space, enclose the key name in quotes.
/v <ValueName> Specifies the name of the registry entry to be added under the specified subkey.
/ve Specifies that the registry entry that is added to the registry has a null value.
/t <Type> Specifies registry types to search. Valid types are: REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_DWORD, REG_BINARY, REG_NONE. If not specified, all types are searched.
/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.
/f Adds the registry entry without prompting for confirmation.
/od Specifies that only differences are displayed. This is the default behavior.
/os Specifies that only matches are displayed. By default, only the differences are listed.
/on Specifies that nothing is displayed. By default, only the differences are listed.
/s Compares all subkeys and entries recursively.
/va Deletes all entries under the specified subkey. Subkeys under the specified subkey are not deleted.
<FileName> Specifies the name and path of the file to be created during the operation. The file must have a .reg extension.
/y Overwrites any existing file with the name FileName without prompting for confirmation.
/se <Separator> Specifies the single value separator to search for in the value name type REG_MULTI_SZ. If Separator is not specified, \0 is used.
/f <Data> Specifies the data or pattern to search for. Use double quotes if a string contains spaces. If not specified, a wildcard (*) is used as the search pattern.
/k Specifies to search in key names only.
/d Specifies to search in data only.
/c Specifies that the query is case sensitive. By default, queries are not case sensitive.
/e Specifies to return only exact matches. By default, all the matches are returned.
/z Specifies to include the numeric equivalent for the registry type in search results.
/? Displays help for reg <operation> at the command prompt.
Marshall Gunnell
Marshall Gunnell is a writer with experience in the data storage industry. He worked at Synology, and most recently as CMO and technical staff writer at StorageReview. He's currently an API/Software Technical Writer at LINE Corporation in Tokyo, Japan, runs ITEnterpriser, a data-storage and cybersecurity-focused online media, and plays with development, with his RAID calculator being his first public project.
Read Full Bio »

The above article may contain affiliate links, which help support How-To Geek.