×

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

What can I do if my computer or laptop is lost or stolen?

The computer loss might bring the owner a stressful situation because it brings a loss in financial and security to the information. But there are a few steps that one...

4 minutes read.

What does Alt+F do?

The computer is one of the most basic needs of every user. Without a computer we cannot do anything, almost in every field. In computer, there are many file menu options...

4 minutes read.

Case Sensitive Languages

Every language, system, or program has the capability to differentiate between different case alphabets. If a programming language doesn’t work properly in upper case and lower case letters interchangeably, it...

4 minutes read.

What is an Alignment?

The phrase aligns, or alignment refers to how text is positioned on the screen. Left-aligned text, for example, Left align, provides a straight line on the left side of the...

4 minutes read.

What is PC

PC stands for personal computer that allows the user to perform certain functions that can reduce the load of daily tasks and be effectively used by an individual. Ed Roberts...

12 minutes read.

Understanding file sizes (Bytes, KB, MB, GB, TB, PB, EB, ZB, YB)

Computer Memory Computer memory is the hardware part of the computer that is used to store data. So, The storage device in a computer is called computer memory. Memory is a hardware...

3 minutes read.

What is the difference between multiprocessor and distributed systems

Multiprocessor A Multiprocessor is a PC framework with at least two focal handling units (CPUs) share full admittance to a typical RAM. The primary goal of utilizing a multiprocessor is to...

3 minutes read.

What is Ray Tracing?

Ray tracing is a technique used in graphic design to produce graphics by following the route that light follows via individual pixels. The effects of light rays on the items...

4 minutes read.

Features of Multimedia

Multimedia consists of two words. One is "multi", and another is "media". Multi means more than one, and media means medium.  So, we can say that Multimedia is a type of...

3 minutes read.

What is a Digital Assistant?

It is a voice assistant or a predictive chatbot that is programmed in such a manner that it can answer the queries of the user or can perform certain simple...

8 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 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.

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.

Types of Network

“The computer network is a set of computers connected to share resources.”An internet itself can be considered the computer network. In computer networks, the computing devices exchange the data with each...

3 minutes read.

What is a Slide?

A slide is typically a single page of a presentation or lecture. Slides are usually used to present information visually, using text, images, charts, and other media to convey ideas...

4 minutes read.

What is Task Pane?

Task panes are interface elements frequently appearing on the right side of the windows in Word, PowerPoint, Excel, and Outlook. Through task panes, users can access interface controls that can...

3 minutes read.

What is an Online Service?

An entity that offers online access to various types of data for diverse purposes is known as an online service. Online banking, education, news, shopping, dating, computer support websites, social networking...

3 minutes read.

What is a Dynamic Website?

There are two types of websites. First static and second dynamic website, but before we go for dynamic, we should know about the static website so that you can easily...

4 minutes read.

Computer Pioneers and people who are CEO

The world of technology has been shaped by several individuals who have made significant contributions as computer pioneers and CEOs of technology companies. This article will take a deeper look...

42 minutes read.

What Hardware Device Drivers should be Updated?

Our recommended hardware for updates is shown below. Driver and other component updates for your computer can resolve problems, improve functionality, and boost stability. How Frequently Should Your Drivers Be Updated? Consider...

6 minutes read.