There are a few possible scenarios where a Windows user might have to or want to use the command line instead of the regedit tool to delete and add keys in the Windows Registry. It can be that a virus or other malicious software has limited access to the Registry so that regedit cannot be used. Another possible reason is script or batch usage to perform operations like adding or deleting keys regularly by simply executing a batch file on the computer system.
The command line tool reg.exe can be used to manage the Registry from the command line. It not only provides access to delete or add but also other options like exporting or importing keys.
Entering reg /? into the command line will display all possible options that are available.

Delete a Registry key from the command line
The reg delete command can be used on local and remote machines. The basic command looks like the following
reg delete keyname valuename parameters
To delete a key with all its values and subkeys a user would have to issue the following command
reg delete HKLM\Software\Test
That’s the most basic form of deleting a Registry key from the command line. This will delete the key Test with all its subkeys and values.
reg delete \\RemoteSystem\HKLM\Software\Test /v Testvalue
This example deletes the Registry value Testvalue under Test on the remote machine RemoteSystem.
Add a Registry key from the command line
The add parameter uses a similar order. The basic command
reg add HKLM\Software\Test
adds the key Test to HKLM\Software\
Important here are the \t and \d parameters which define the Regkey data type and the value that is assigned.
reg add HKLM\Software\Test /v Testdata /t REG_BINARY \d ffffff
Adds the value Testdata to the key Test that is of type reg_binary and contains the data ffffff.
Using the /? parameter will explain every command in great detail. This concludes the little tutorial on how to delete and add Registry keys from the command line.
Enjoyed the article?: Then sign-up for our free newsletter or RSS feed to kick off your day with the latest technology news and tips, or share the article with your friends and contacts on Facebook or Twitter.Related Articles:
Registry BenchmarkCheck and Compress the Registry
Nirsoft Command Line Tool
Make Screenshots Of The Command Line
Linux tips: Encrypting and decrypting files from command line with gpg

Nice! Thanks for the tip :)