Modify Windows Registry via Command Prompt (Step-by-Step)

The Windows Registry is a database of information about PC settings and various configurations of applications for systems running on Microsoft’s Windows operating system. Although not every application needs to run on a configuration database stored in the Windows registry (some store configuration data in an XML file or a separate executable file), the registry plays a vital role in the proper functioning of a Windows PC.

Windows gives users the option to edit these registries in case they want to change the configuration settings of an application or program on their computer. Let’s learn more about how to use these registries and edit them according to your choice:

How does the Windows registry work?

The information stored in the Windows registry is organized at three distinct registry levels:

  • Registry Hives:

These are collections of keys, subkeys, and registry values represented by folders. These folders are divided into subfolders based on the type of data values they hold.

  • Registry entries:

These are the subfolders that make up Registry Hives. These are considered standard organizational units in the Windows registry. These are similar to folders in Windows File Explorer, which contain different types of files on your computer. Similarly, registry keys hold registry values.

  • Registry Value:

These are instructions or information for configuration and system settings. Each registry value contains instructions for specific system settings, applications, or related configurations.

How do I edit the registry with Windows Command Prompt?

Just in case, you need to adjust the Windows registry; You can navigate the process through the command prompt on your Windows 10 PC. All you need to do is follow the step-by-step tutorial of editing the registry in the following Windows Command Prompt:

Open the Command Prompt

First, head to the Windows search bar.

Then, type cmd in the search barThe search results will display the Command Prompt as the top result.

Right-click on the Command Prompt option and click Run as Administrator.

This will open the Command Prompt in administrator mode on your Windows PC.

Edit the type of operation for the registry

Step 1: Run the following command to get a list of all the actions you can perform to edit the Windows registry.

REG /?

Action types define what changes you need to make in the Windows registry, for example, by adding an action type to add a child.

Step 2: The Command Prompt will display all the actions along with the return code commands for each action. The return code determines whether the command execution failed or succeeded.

Note: Microsoft provides the content in the following table

operatortask
AddAdd a new entry to the registry
CompareCompare two or more registry subkeys or entries.
CopyCopy the registry key to a specified location on a local or remote computer.
LoadWrites saved children and entries to different children in the registry. This is intended to be used with temporary files for troubleshooting or editing registry keys.
RestoreWrites saved children and entries back to the registry.
QueryReturns a list of the next level of children and entries located under the specified subkey in the registry.
ImportCopy the contents of the file containing the exported registry subkeys, entries, and values to the local computer’s registry.
ExportCopy the specified subkeys, entries, and values of the local computer to a file for transfer to other servers.
SaveSaves a copy of the specified subkeys, entries, and values of the registry in the specified file.
DeleteDelete one or more children.
UnloadRemove the registry portion that was loaded using the REG LOAD operation.

Source: Microsoft

Return codeoutcome
0succeed
1fail

Source: Microsoft

Look for syntax

To find the syntax, all you need to do is add the operation name between the previous REG commands. Like this-

REG <Operation>

This particular step will generate all the information you need about that particular action, including all the parameters and syntax. Let’s take the Add operation type as an example to find the syntax.

Perform editing tasks using an action type: Add a child or entry

How do I edit the registry with Windows Command Prompt? As follows:

Step 1: You can add the child key to the registry via the Add operation. To start editing, you’ll need to place the action type between the REG commands.

Since we’re using the Add Action Type, you’ll need to enter the command –

REG <Add>

Step 2: The syntax is on the second line of the prompt –

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

Over here-

  • <KeyName> specify the path of the child. Typically, the root key used for the path is specified by HKLM or HKU.
  • /v ValueName specifies the name of the child.

No additional syntax arguments are required in the case of adding an action type.

Step 3: Suppose your sub-key name is MySubkey; The commands to be used with the action type will be –

REG ADD HKLM\Software\MySubkey

Delete the child

Step 1: The syntax for the deletion operation is –

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

Step 2: Suppose you need to delete the same subkey you created in the previous step; The order will be-

REG DELETE HKLM\Software\MySubkey

Step 3: Type YES to confirm the deletion command.

Step 4: Press Enter.

Step-by-step tutorial for Windows Command Prompt to edit registry: These are just two operations. Each operation requires a different syntax, which you now know how to understand, and each operation performs a different task. You can visit this documentation published by Microsoft to learn more about registry operation types, syntax, and parameters.

Disclaimer: Why should you avoid tweaking the Windows registry?

Any changes you make in Control Panel settings, system associations, software or application installations, and so on are automatically reflected in the Windows registry. If you try to manually edit the Windows registry; You could end up breaking any of these settings, configurations, and system policies. This can lead to some computer issues such as system crashes, corrupted applications, drives that won’t boot, issues in saved files, and system folders.

Therefore, it is recommended that you do not attempt to tweak the Windows registry unless you fully understand all the syntax and parameters, or you don’t need to.