How to Edit the Windows Registry in the Command Prompt

The Registry Editor is usually the go-to for Windows users looking to tweak the Windows Registry. However, if you prefer to avoid a cluttered GUI and numerous clicks, there’s a straightforward alternative: the Command Prompt.

Even though it requires a bit more technical knowledge compared to the Registry Editor, this guide will help you get started smoothly.

How to View the List of Registry Commands in Command Prompt

Editing the registry via Command Line doesn’t involve many commands. To see all available commands, open Command Prompt as an administrator and input the following command:

reg /?

Command Prompt will display commands like reg add, reg delete, reg copy, and reg save.

To get more information on a specific command, append the /? switch. For example, to learn about the reg add command, use:

reg add /?

This will provide details on its functionality and usage.

If you’re finding the commands complex, don’t worry. We’ll break them down to help you get started.

Add and Delete Keys in the Windows Registry

To add a key to the registry using Command Prompt, employ the reg add command. You’ll need to specify the path to the new key and, optionally, use the /f switch to bypass the confirmation prompt.

Example:

REG add HKLM\SOFTWARE\MyNewKey /f

This command adds the MyNewKey subkey to the HKLM\SOFTWARE key. You can check its presence in the Registry Editor.

To delete the key, replace add with delete in the command:

reg delete HKLM\SOFTWARE\MyNewKey /f

The MyNewKey subkey will be removed from the Registry Editor.

How to Add, Modify, and Delete Values in the Windows Registry

Adding or modifying a value involves the reg add command. You must specify the value name (/v), type (/t), and data (/d). For example:

reg add HKLM\SOFTWARE\MyNewKey /v MyValue /t REG_DWORD /d "1" /f

Once executed, the value will appear in the Registry Editor. If the key does not exist, it will be created.

The Windows Registry supports several value types:

Value Type Description
REG_NONE No value type
REG_SZ String value
REG_MULTI_SZ Multi-string value
REG_EXPAND_SZ Expanded string value
REG_DWORD 32-bit DWORD value
REG_QWORD 64-bit QWORD value
REG_BINARY Binary value

To remove a value, use reg delete with the key path and value name:

reg delete HKLM\SOFTWARE\MyNewKey /v MyValue /f

The value will be removed from the Registry Editor.

How to Copy Registry Entries From One Key to Another

Copying values from one key to another is simple with the reg copy command. Specify the source and destination keys:

reg copy HKLM\SOFTWARE\MyNewKey1 HKLM\SOFTWARE\MyNewKey2 /s

The /s switch copies all subkeys and values from MyNewKey1 to MyNewKey2.

Note that copying specific values requires the Registry Editor.

How to Import Registry Entries

To import a Windows Registry file, use reg import followed by the file path:

reg import C:\Users\CHIFUNDO\Desktop\MyRegFile.reg

The contents of the file will merge with the registry upon execution.

How to Export Registry Entries

Exporting a registry key requires the reg export command. Specify the key path and the output file:

reg export "HKLM\SOFTWARE\MyNewKey" D:\Reg_Backup\CHIFUNDO\Desktop\MyRegFile.reg

The exported file, MyRegFile.reg, will be found at the specified location.

To export a specific value, use reg query and redirect the output to a file:

reg query HKLM\SOFTWARE\MyNewKey /v MyValue > C:\Users\CHIFUNDO\Desktop\MyRegFile.reg

This file will contain only the specified value.

How to Save Registry Entries

To save keys to an existing registry or text file, use the reg save command:

reg save HKLM\SOFTWARE\MyNewKey2 C:\Users\CHIFUNDO\Desktop\MyRegFile.hiv /y

The /y switch forces the overwrite without prompting. Note that the saved file is a binary and not human-readable.

How to Restore Registry Entries

To restore keys and values from a backup, use the reg restore command:

reg restore HKLM\SOFTWARE\MyNewKey2 C:\Users\CHIFUNDO\Desktop\MyRegFile.hiv

The key MyNewKey2 will revert to its state during the backup.

Tweak the Registry Without the Registry Editor

While the Command Prompt might not cover all functionalities of the Registry Editor, it serves as a quick alternative for registry tweaks. It’s advanced but manageable even for average users with careful guidance.

Always remember to create a system restore point to protect your system from unintended changes.