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.
Next, right-click the “Command Prompt” app in the search results, and select “Run As Administrator” from the menu.
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:
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:
So, if I wanted help on the “Add” operation, I would run:
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:
The
So, let’s say we want to add a subkey named HowToGeekSubkey under HKEY_LOCAL_MACHINE\Software. We’ll run the following command:
If the operation was successfully executed, the Command Prompt will let you know.
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.
Navigate to the location of the newly added subkey. In our case: HKEY_LOCAL_MACHINE > SOFTWARE > HowToGeekSubkey.
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:
The parameters that we care about for now are the same as before. That is,
If we want to delete the HowToGeekSubkey subkey from HKEY_LOCAL_MACHINE\Software that we just created, we will run this command:
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.
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.