×

How to edit the registry from the command line

Editing from the command line is one of the ways of editing the registry. Still, before editing the registry, it is always recommended to back up the registry and computer so that if any mistake occurs, we can roll back to a safe state again.

Microsoft state that editing and modifying the Windows registry should be done by admins, IT professionals or under the supervision of advanced users.

Microsoft Windows Vista, XP, 7, 8, 10, and 11 users

Using the "reg" command, Microsoft Windows users of XP and later versions can edit the registry from a command prompt.

The syntax of the command is "C:\>reg".

Microsoft Windows 95, 98, ME, and 2000 users

These Microsoft Windows users can get the registry from the command prompt using the "regedit" command.

To edit the registry through the command prompt, first, start from the command prompt in admin mode.

To do this, type "cmd" in the bottom left search bar of the windows. Right-click on the command prompt and then select on "Run as Administrator" option. Then the command prompt is opened in admin mode. Then one can edit the registry.

How to edit the registry from the command line

Now type “REG /?”  in theprompt to get the list of operations specified by the Microsoft.

How to edit the registry from the command line

Registry Operations given by the Microsoft are:

  • Add: This adds an entry or subkey to the registry.
  • Compare: This compares the two or more than two subkeys or entries in the registry.
  • Copy: This copies a registry value to another location.
  • Delete: This deletes an entry or subkeys which are selected.
  • Export: This exports values, subkeys, and entries by copying and then transfers to other servers.
  • Import: Carbons the file contents, that contain shipped entries and values, into the local computer's registry present in the user’s device.
  • Load: Writes into different subkey values of saved subkeys.
  • Query: Next tier list of subkeys is returned.
  • Restore: Saved subkeys and entries are written back into the registry.
  • Save: Specified subkeys, entries copy is saved to the registry at a specified file location.
  • Unload: Files that are loaded using REG LOAD operation are removed.

Registry operations that user get from the command line helps for getting information about a specific operation that user needs. The following syntax is used to get help

REG <Operation> /?

Example: For add operation, if a user wants help, type REG ADD /?

Then it returns all the parameters, syntax, and examples used for add operation.

Add value to a registry

Command:  reg add HKLM\software\sisl\dataoprt /v server /d 192.168.1.6 /f /reg:64

/v for a key value name

/d for the value of key

/f means force add

/reg:64 for 64 bit machine

/reg:32 for 32 bit machine

How to edit the registry from the command line

Change the existing value in a registry

Command:   reg add HKLM\software\sisl\dataoprt /v server /d anyname /f /reg:64

Delete a value

Command:   reg delete HKLM\software\sisl\dataport /v server /f /reg:64

How to edit the registry from the command line

REG operations

Operations and Syntax

OperationSyntax
AddREG ADD <Key_Name> [{/v Value_Name | /ve}] [/t DataType] [/s Separator] [/d Data] [/f]
CompareREG COMPARE <Key_Name1> <Key_Name2> [{/v Value_Name | /ve}] [{/oa | /od | /os | on}] [/s]
CopyREG COPY <Key_Name1> <Key_Name2> [/s] [/f]
DeleteREG DELETE <Key_Name> [{/v Value_Name | /ve | /va}] [/f]
ExportREG EXPORT Key_Name File_Name [/y]
ImportREG IMPORT File_Name
LoadREG LOAD KeyName File_Name
QueryREG QUERY <Key_Name> [{/v <Value_Name> | /ve}] [/s] [/se <Separator>] [/f <Data>] [{/k | /d}] [/c] [/e] [/t <Type>] [/z]
RestoreREG RESTORE <Key_Name> <File_Name>
SaveREG SAVE <Key_Name> <File_Name> [/y]
UnloadREG UNLOAD <Key_Name>

Parameter and its Description

ParameterDescription
<KeyName>The full path of the entry or subkey is stated, which is to be added. The key name should contain a valid root key like HKLM, HKU, HKCC, HKCR, HKCU
/v <ValueName>States the registry entry name to be added under the specified subkey.
/veThe registry to be added new to the registry is given a null value.
/t <Type>Registry types that are to be typed are stated. If nothing is specified, each and every type is searched. 
/s <Separator>The character to be used for separating the multiple instances of data for the REG_MULTI_SZ data type is stated. The default separator is “\0”(null) when nothing is detailed.
/d <Data>Data for new registry entries is stated.
/fWith this registry, an entry is added with prompting for confirmation.
/oaOnly differences are listed by default. This states that all matches and differences are listed.
/odStates that differences are only listed. /od is the default behavior.
/osStates are only matched are displayed. Only differences are listed by default.
/onStates that anything is not displayed. Only differences are listed by default.
/sall subkeys and entries are compared recursively.
/vaUnder the specified subkey, all entries are deleted, and specified subkeys are not deleted. 
<FileName>Used to specify the name and path of a file to be created while undergoing an operation. The ".reg" extension must be there for a file.
/yWith the name "FileName," existing file is overwritten without prompting for confirmation.
/se <Separator>In the value name type “REG_MULTI_SZ”, this parameter is used to specify the value separator to search. If no separator is specified, \0 is used.
/f <Data>States the pattern or data to search.
/kStates that the search should be done in key names only.
/dStates that the search should be done in data only.
/cMatches are case insensitive, but this states that queries are case sensitive.
/eStates that only the exact matched values should be returned.
/zIn the search results for registry type, it states to contain the numeric equivalent.
/?At the command prompt, it will output the help for "reg" operation.

Related Topics

How to edit the registry from the command line

Editing from the command line is one of the ways of editing the registry. Still, before editing the registry, it is always recommended to back up the registry and computer...

4 minutes read.

What does Alt+D do?

Computer keyboard shortcut keys play an important role in the working of any computer user. We can do anything from the mouse and keyboard, but shortcut keys provide data in...

3 minutes read.

What are the currently available antivirus programs?

An antivirus program or software is a kind of software used to detect viruses in the system and protect the computer or network from attacks. Whenever the virus gets into the...

4 minutes read.

What is Binary?

There are four types of the number system in computer applications through which we represent the different numbers. Before moving to binary numbers, let's discuss the rest of the number...

5 minutes read.

Version Control System

There are many problems that are faced by a multinational organization. These problems are the backup of data, storing several versions of files and collaboration of employees. All these problems...

6 minutes read.

Low Level Language in Computer

Low Level Language: The computer languages are those languages by which the user can communicate with the machine. There are various types of programming languages via we can write the...

5 minutes read.

How to associate a file with a program?

How to associate a file with a program in Windows? By default, a particular program is selected by the Windows to open each file type, but you may re-associate a file...

4 minutes read.

What are the advantages of the Internet?

Advantages of the Internet What is the Internet? Today’s world is connected through an internet so that imaging a day without the Internet is like a scary nightmare. The Internet is one...

6 minutes read.

What is A4?

A4 is a standard paper size widely used for printing documents and other materials. It is 210 x 297 millimeters or about 8.27 x 11.69 inches. It is part of...

7 minutes read.

Basic Network Troubleshooting

The term Basic Network Troubleshooting means to determine the issue related to the network through a continuous process and solve them using practically examined and reliable solutions. The methods that...

9 minutes read.

What is an Output Device?

The equipment that accepts input or data from a computer commonly for display, projection, or physical reproduction. For example, the image depicts an inkjet printer, an output device that creates...

6 minutes read.

What Does Alt + L Do?

The keyboard shortcut, "Alt+L"  is frequently used to open the Developer Tab in the Ribbon. Open the program in which you want to use the Developer tab. Press and hold the "Alt"...

3 minutes read.

What programs can I use for speech recognition?

Since its inception, voice recognition software has advanced significantly. It can be utilised for a variety of things, such as speech-to-text software and voice commands on desktop computers and mobile...

3 minutes read.

Uninstalling Software or Apps in Windows

How to uninstall software in Windows? Unwanted software can be removed from your computer's hard drive using several third-party programs and the built-in tools that Windows 10 and Windows 11 provide. Applications...

4 minutes read.

What are Toggle keys?

keys that are used to turn on or off a function or the keys used to switch between two functions is called the Toggle key. The caps lock key, scroll...

3 minutes read.

What is a LED Monitor?

An LED monitor, also known as an LED display, is a computer or television with a flat panel and a screen that emits light. The most advanced computer display technology...

5 minutes read.

What is AIMBOT?

In shooter games, an AIMBOT is any cheating software or game hack that enables a player to aim automatically and, in some circumstances, auto-shoot (trigger bot). In first-person shooter games,...

4 minutes read.

What does Alt + O do?

Alt + O is used for opening the Format file menu. Alt + O is a shortcut that can be used by pressing the "Alt" and "O" keys. As shown in...

4 minutes read.

What is CMOS?

A compact device or system that stores data or information on the computer is used to save BIOS settings on pc motherboards. It is referred to as non-volatile bios memory....

3 minutes read.

What is Jacquard Loom?

Jacquard attachment, Jacquard mechanism and Jacquard Loom are all the same. This Jacquard Loom machine completely changed, improved and made a lot of specific changes in the whole industrial department. Jacquard...

3 minutes read.