The Windows Registry is a database of information, settings, options, and other values for software and hardware installed on all versions of Microsoft Windows operating systems. When a program is installed, a new subkey is created in the registry. This subkey contains settings specific to that program, such as its location, version, and primary executable. Windows and a lot of third-party apps store settings in the registry. In this post, we will show you how to edit the Registry from Command Prompt in Windows 11/10.
How to edit Registry from Command Prompt
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. Since this is a registry operation, it is recommended that you back up the registry or create a system restore point in case the procedure goes wrong.
Once you have taken the necessary precautionary measures, you can proceed as follows:
Press Windows key + R to invoke the Run dialog.
In the Run dialog box, type cmd and then press CTRL + SHIFT + ENTER to open Command Prompt in admin mode.
To get the list of operations, run the command below:
REG /?
The Operation List will appear, as well as the Return Code for each command.
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> /?
For example, if you want help on the Add operation, run the following command:
REG ADD /?
When the command executes, 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
To begin, below is the syntax for REG ADD 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. The /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 TheWindowsClubSubkey under HKLM\Software. The command (syntax) will look like this:
REG ADD HKLM\Software\TheWindowsClubSubkey
Once the command executes, the subkey will be added to the registry. To confirm, do the following:
- Press the Windows key + R to invoke the Run dialog.
- In the Run dialog box, type regedit and hit Enter to open Registry Editor.
- Navigate or jump to the registry key path below:
HKEY_LOCAL_MACHINE > SOFTWARE > TheWindowsClubSubkey
Delete a SubKey or Entry from the Registry
To delete a subkey or entry from the registry, run the following syntax:
REG DELETE <KeyName> [{/v ValueName | /ve | /va}] [/f]
So, let’s say we want to delete/remove the subkey named TheWindowsClubSubkey under HKLM\Software, the command (syntax) will look like this:
REG DELETE HKLM\Software\TheWindowsClubSubkey
You’ll be prompted if you really want to delete the subkey. Type Yes and hit Enter.
Once the command executes, the subkey will be deleted from the registry.
That’s it on how to edit the Registry from Command Prompt in Windows 11/10.