Undetectable Humanizer: Lifetime Subscription
Transform AI-Generated Text into Human-Like, High-Ranking Content & Bypass Even the Most Sophisticated AI Detectors
Get 95% Deal

How To Delete And Add Registry Keys From The Command Line

Martin Brinkmann
Apr 5, 2010
Updated • Nov 6, 2016
Tutorials, Windows tips
|
6

There are a few scenarios where a Windows user might have to or want to use the command line instead of the Regedit tool to change, delete or 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 which ships with the Windows operating system can be used to manage the Registry from the command line. It provides you with access to delete or add but also other options like exporting, comparing or importing keys.

reg.exe: Registry command line tool

Entering reg /? on the command line displays all possible options that are available. You can spawn a command prompt with a tap on the Windows-key, typing cmd.exe and hitting the Enter-key.

Delete a Registry key using 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 run 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 switch uses a similar structure. The basic command

reg add HKLM\Software\Test

adds the key Test to HKLM\Software\

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

Other handy options that reg.exe provides you with include exporting the full Registry or part of it using the /export parameter,  or using the /import parameter to import data to the Registry.

Using the /? parameter explains every command in great detail. This concludes the little tutorial on how to delete and add Registry keys from the command line.

Update: This method works in all supported versions of the Windows operating system.

Summary
How To Delete And Add Registry Keys From The Command Line
Article Name
How To Delete And Add Registry Keys From The Command Line
Description
The tutorial explains how to add or delete keys or values from the Windows Registry using the command line.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Previous Post: «
Next Post: «

Comments

  1. Guard said on October 7, 2013 at 2:15 pm
    Reply

    This does not work with HEX values!

    If you type A-F it says wrong value.

    1. Duggy Fresh said on April 12, 2014 at 12:26 am
      Reply

      Bit of a late reply, I know, but prefix HEX values with “0x”.

      Duggy.

  2. Hentie said on April 2, 2012 at 11:53 am
    Reply

    Typo on \d:

    reg add HKLM\Software\Test /v Testdata /t REG_BINARY \d ffffff

    should be

    reg add HKLM\Software\Test /v Testdata /t REG_BINARY /d ffffff

    1. Martin Brinkmann said on April 2, 2012 at 12:09 pm
      Reply

      Well spotted, thanks and corrected.

  3. Zim said on April 5, 2010 at 3:15 pm
    Reply

    Nice! Thanks for the tip :)

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.