How to Edit the Windows Registry from the Command Prompt

Microsoft Windows 10 logo

Windows and a large number of third-party applications store the settings in the registry. If you want to modify the registry, you can do this in several ways. Here’s how to edit the Windows registry from the Command Prompt.

Before you begin, it is important that you save registry, as well as your computer, before making any changes. A wrong move can make your system unstable or even completely unusable. You can also create a system restore point to quickly restore your system if something goes wrong.

RELATED: The 10 best registry hacks for Windows 10

Microsoft has publicly stated that adding, changing, or removing Windows subkeys and registry values ​​should only be done by advanced users, administrators, and IT professionals. Be careful before making changes.

Edit Windows Registry from the Command Prompt

There is a long list of reg operations. We will give some examples of how to perform basic operations. If you are interested in the full list of operations, each syntax and what the parameters of each syntax represent, see the list at the bottom of the article.

Once you’re ready to edit the Windows registry, open command prompt as administrator.

Open the command prompt as administrator

To open the command prompt as an administrator, type “cmd” in the Windows search bar.

cmd search in windows search bar

Then right-click on the “Command Prompt” application in the search results and select “Run as administrator” from the menu.

Command Prompt Application in Windows Search

The command prompt will now open in administrator mode, and we can start editing the Windows registry.

Learn the types of operations

We will give a full list of reg commands and each respective syntax later. For now, you can get a list of transaction types, as well as additional help for each transaction, from the command prompt.

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

For a list of operations, run this command:

REG /?

The list of operations appears, as well as the return code for each order.

Command to obtain the list of operations

Here is the list of operations and what each does, like described by Microsoft:

Add: Adds a new subkey or entry to the registry.
Compare: Compares the specified subkeys or registry entries.
Copy: Copies a registry entry to a specified location on a local or remote machine.
Remove: Delete a subkey or entries.
Export: Copies the specified subkeys, entries, and values ​​from the local computer to a file for transfer to other servers.
Import: Copies the contents of a file containing exported registry subkeys, entries, and values ​​to the registry on the local computer.
Charge: Writes the subkeys and entries saved in a different subkey to the registry. It is intended for use with temporary files used for troubleshooting or modifying registry entries.
Request: Returns a list of the next level of subkeys and entries that are found under a specified subkey in the registry.
Restore: Writes the subkeys and entries saved in the registry.
To save: Saves a copy of the specified registry subkeys, entries, and values ​​to a specified file.
Download: Delete a section of the loaded register using REG LOAD surgery.

And, the return codes:

0: Success
1: Failed

For help with a specific operation, add the name of the operation in the middle of the previous command:

REG /?

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


Run the command to get help on a specific operation

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

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

Add a subkey or entry to the registry

First, here is the syntax of REG ADD that we got using REG ADD /? order:

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

the specifies the full path of the subkey. The 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 specifies the name of the registry entry to add under the specified subkey. We’ll define the rest of the parameters later, but for this example, that’s all we will need.

So suppose we want to add a subkey named HowToGeekSubkey under HKEY_LOCAL_MACHINE Software. We will execute the following command:

REG ADD HKLM Software HowToGeekSubkey

If the operation has been successfully completed, the command prompt will let you know.

command to add a subkey to the registry

If you want to verify that the operation was successful, you can search for yourself using the Registry Editor.

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

open registry editor

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

How geek subkey in the registry

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

Delete a subkey or entry from the registry

Here is the syntax of the REG DELETE operation:

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

The parameters we care about at the moment are the same as before. This is, and / v value_name.

If we want to delete the HowToGeekSubkey subkey from the HKEY_LOCAL_MACHINE software we just created, we will execute this command:

REG DELETE HKLM Software HowToGeekSubkey

This time, you will 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 has been completed successfully.

Delete the subkey from the registry

You can crosscheck that the subkey has been deleted from Registry Editor. Navigate to the location of the subkey and see if it has been deleted.

REG operations, description of syntax and parameters

Although we have covered only two simple examples, there is a decent size list of REG operations. Each operation can have a potentially complex syntax. For easy access we will list all the details provided by Microsoft here.

Operation and syntax

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

REG COMPARE [{/v ValueName | /ve}] [{/oa | /od | /os | on}] [/s]

REG COPY [/s] [/f]

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


REG EXPORT KeyName FileName [/y]


REG LOAD KeyName FileName


REG QUERY [{/v[{/v[{/v[{/v | / ve}] [/s] [/se[/se[/se[/se][/F[/f[/F[/f] [{/k | /d}] [/c] [/e] [/t[/t[/t[/t] [/z]



to save




Parameter and description of the parameter

The description

Specifies the full path of the subkey or entry to add. To specify a remote computer, include the computer name (in \ format) as part of the KeyName. Omitting \ ComputerName results in the default operation on the local computer. The KeyName must include a valid root key. The valid root keys for the local computer are: HKLM, HKCU, HKCR, HKU and HKCC. If a remote computer is specified, the valid root keys are: HKLM and HKU. If the name of the registry key contains a space, enclose it in quotation marks.
/ v
Specifies the name of the registry entry to add under the specified subkey.
/ ve
Specifies that the registry entry that is added to the registry has a value of zero.
/ t
Specifies the types of registers 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
Specifies the character to use to separate multiple instances of data when the REG_MULTI_SZ data type is specified and multiple entries are to be listed. If not specified, the default separator is 0.
Specifies the data for the new registry entry.
/ F
Adds the registry entry without asking for confirmation.
/ oa

Specifies that all differences and matches are displayed. By default, only the differences are listed.

/ od
Specifies that only differences are displayed. This is the default behavior.
/ bone
Specifies that only matches are displayed. By default, only the differences are listed.
Specifies that nothing is displayed. By default, only the differences are listed.
/ s
Compares all subkeys and entries recursively.
Deletes all entries under the specified subkey. The subkeys under the specified subkey are not deleted.

Specifies the name and path of the file to create during the operation. The file must have a .reg extension.
/ y
Replaces any existing file with the name FileName without asking for confirmation.
/ se
Specifies the unique value separator to search for in the REG_MULTI_SZ value name type. If the separator is not specified, 0 is used.
/ F
Specifies the data or model to search for. Use double quotes if a string contains spaces. If not specified, a wildcard (*) is used as a research model.
/ k
Specifies to search only in key names.
Specifies to search only in the data.
/ vs
Specifies that the request is case-sensitive. By default, queries are not case-sensitive.
/ e
Specifies to return only exact matches. By default, all matches are returned.
/ z
Specifies to include the digital equivalent of the registry type in the search results.
Displays help for reg at the command prompt.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.