Like previous versions of Windows, Windows 10 also includes a registry editor feature in the command prompt. The reg.exe feature is a command line tool that allows the user to edit the Registry using CMD.
Use Of Registry Editor!
When you search for how to change something in Windows, you will find articles that help you make those changes by making changes to the registry values. The Registry is a database that stores the configuration settings included with Windows.
There are a lot of advanced settings available in the Registry. Some of these settings are also available in the Group Policy Settings. However, the Group policy is only available to the Professional version of Windows. So if you wish to make changes to your Windows, Registry Editor may be the only way to do so.
How To Edit Registry Values?
Caution: Remember that if you don’t know what changes you need to make and delete some important registry files, you may accidentally damage your system. Remember to backup your registry and windows before making any such changes.
You can edit the registry using the GUI available in Windows. You can simply search for regedit in the Run command.
The GUI houses a tree-like interface for the database it contains, which can be confusing at times. Also, detailed information of the values must be known along with the location of all the database entries and their values.
You can alternatively use the Command Prompt to make the same changes to the registry. It has several advantages like editing the entries faster as you don’t have to browse the tree-like database, and you get the flexibility of implementing tweaks using scripts. Here I will show you how to make changes to the registry database using Command Prompt.
How To Edit The Registry Using CMD?
To run reg.exe in Windows 10, open Command Prompt as an administrator. To do this, search for Command Prompt in Start and select Run as administrator in the right-click menu.
To run the tool, you can see the available parameters by typing the following command in the input field:
reg /?
This command will display the Operation Parameters list available that can be used to make changes to the registry along with the return codes for the same. For more information including how to make changes to a registry, you need to follow with the command:
REG Operation /?
The operations available are:
1) QUERY | 2) ADD | 3) DELETE | 4) COPY |
5) SAVE | 6) LOAD | 7) UNLOAD | 8) RESTORE |
9) COMPARE | 10) EXPORT |11) IMPORT | 12) FLAGS
The directories are available as abbreviations of their names. These abbreviations represent the root keys in the registry. They are:
- HKCR: HKEY_CLASSES_ROOT
- HKCU: HKEY_CURRENT_USER
- HKLM: HKEY_LOCAL_MACHINE
- HKU: HKEY_USERS
- HKCC: HKEY_CURRENT_CONFIG
You may see these abbreviations in the next part of the article, so now you know what these mean.
How To Use Reg.exe To Make Changes To The Registry?
There are some basic operations that often come up in the articles that instruct how to make changes to windows, and these include adding or deleting a key, copying a key from one directory to another, importing or exporting registry files and copying or restoring registry files.
Now I will show how to make these changes to registry- using the information obtained above –by using CMD.
1) ADDING OR DELETING REGISTRY FILES
The regedit command line syntax for adding a key is
REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f] [/reg: 32 | /reg: 64]
The syntax for deleting a key is
REG DELETE KeyName [{/v ValueName | /ve | /va}] [/f] [/reg: 32 | /reg: 64]
What they mean:
Syntax Value | Definitions |
KeyName | Defines the path to the subkey or registry entry. The syntax for the same is:
[\\Machine\ROOTKEY\Subkey Machine: name of the PC you want to make the changes to Omitting defaults it to the current machine. ROOTKEY: Here you enter the abbreviations listed above for the directories i.e. HKLM, HKCU, HKCR, HKU, and HKCC. Subkey: Here you enter the full name of the registry key under selected ROOTKEY.
|
/v Valuename | The value name under the subkey to add or delete.
If omitted during delete, all subkey and values under the KeyName are deleted |
/ve | Defines empty value for the key you will add or delete |
/va | Defines delete all values under this key (KeyName) |
/t Type | Defines the type of key entry to be added
The valid types include:
|
/s Separator | Defines the character you use as a separator for the data string for REG_MULTI_SZ. The default value is \0 if not specified. |
/d Data | This defines the data to assign to the registry Valuename being added |
/f | This forces the overwrite entry without the UAC prompt for confirmation |
/reg: 32 | This specifies the key to be accessed using the 32-bit registry view |
/reg: 64 | This specifies the key to be accessed using the 64-bit registry view. |
Example:
To add a subkey under HKEY_Local_Machine\System named SubKey123, the command for that is:
REG ADD HKLM\System\SubKey123 /f
To add a new DWORD (32-bit) Value entry named AppData1 with the value set to 1, the command for that is:
REG ADD \\ComputerName\HKLM\System\ SubKey123 /v AppData1 /t REG_DWORD /d 1 /f
Note: replace (\\ComputerName) with the name of the computer on the network. This is necessary to be specified if you are making changes to a remote computer.
To delete the subkey named SubKey123, the command for that is:
REG DELETE HKLM\System\SubKey123 /f
To delete the registry entry AppData1 on a remote computer, the command for that is:
REG DELETE \\ComputerName\HKLM\System\SubKey123 /v AppData1 /f
To only delete the entries under SubKey123 that have no value, the command for that is:
REG DELETE HKLM\System\SubKey123 /ve
2 ) COPYING REGISTRY FILES
The regedit command line syntax for copying a file is:
REG COPY Keyname1 Keyname2 [/s] [/f] [/reg: 32 | /reg: 64]
What they mean:
Syntax Value | Definition |
KeyName | Defines the path to the subkey or registry entry. The syntax for the same is:
[\\Machine\ROOTKEY\Subkey Machine: name of the PC you want to make the changes to Omitting defaults it to the current machine.
ROOTKEY: Here you enter the abbreviations listed above for the directories i.e. HKLM, HKCU, HKCR, HKU, and HKCC.
Subkey: Here you enter the full name of the registry key under selected ROOTKEY.
Keyname1: defines the path to the subkey you want to copy. Keyname2: defines the path to the subkey paste destination |
/s | Copies all the subkey and values |
/f | Forces the copy without the UAC prompt for confirmation |
/reg: 32 | This specifies the key to be accessed using the 32-bit registry view |
/reg: 64 | This specifies the key to be accessed using the 64-bit registry view. |
Example:
To export all the content under the subkey named SubKey123 to D:\Backups, the command for that is:
REG EXPORT HKLM\System\SubKey123 D:\Backups\appbkup.reg /y
To import all the subkey entries and values under subkey named SubKey123, the command for the same is:
REG IMPORT D:\Backups\appbkuptdy.reg
3) SAVING AND RESTORING REGISTRY ENTRIES
The regedit command line syntax to save the registry files is:
REG SAVE KeyName FileName [/y] [/reg: 32 | /reg: 64]
The syntax to restore these registry files is:
REG RESTORE KeyName FileName
What they mean:
Syntax Value | Definition |
KeyName | Defines the path to the subkey or registry entry. The syntax for the same is:
[\\Machine\ROOTKEY\Subkey Machine: name of the PC you want to make the changes to Omitting defaults it to the current machine.
ROOTKEY: Here you enter the abbreviations listed above for the directories i.e. HKLM, HKCU, HKCR, HKU, and HKCC.
Subkey: Here you enter the full name of the registry key under selected ROOTKEY. |
FileName | This specifies the name and path of the .hiv file to be saved or restored |
/y | Force overwrites the registry content without UAC prompt for confirmation |
/reg: 32 | This specifies the key to be accessed using the 32-bit registry view |
/reg: 64 | This specifies the key to be accessed using the 64-bit registry view. |
Note: The files generated under the save and export commands are different.
- SAVE saves the file in the Registry’s native “hive” format and preserves the key ownership and ACLs.
- EXPORT saves the file in a textual format and is suitable for distribution as the .reg file format does not preserve metadata.
Example:
To save a copy of subkey entries and values within the subkey named SubKey123, the regedit command for that is:
REG SAVE HKLM\System\SubKey123 D:\Backups\appbkuptdy.hiv /y
To restore this file including all its contents, the command is:
REG RESTORE HKLM\System\SubKey123 D:\Backups\appbkuptdy.hiv /y
Conclusion
The feature reg.exe has been a part of Windows for a long time now, and now you know how to use command prompt to make changes to the registry using registry key command lines. You may find this technique much faster and easier than going through the tree-like branching of the directories interface the GUI provides.
Remember, however, that making changes to the registry is risky as doing this incorrectly may break your system totally. So check for any spelling errors before you finalize any change. Did you find this guide useful? Comment below if you found this guide useful or have some follow up queries.