How can I edit the Registry from the command prompt?

Tip: If you're attempting to edit the Registry from the command line because you're unable to get into normal windows try first booting into Windows Safe Mode and run regedit from Safe Mode.

Microsoft Windows XP users

Microsoft Windows XP users can view, edit, and modify their Registry from the MS-DOS command prompt by using the reg command. See the reg command page for additional information and examples.

In addition to using this command Windows XP users can also use the below solution to edit and modify their Registry from the command prompt.

Microsoft Windows 95, 98, ME, and 2000 users

By default Microsoft Windows 95, 98, ME, and 2000 users can import Registry files from the command prompt using the regedit command. Using this command and a Registry file that contains the proper commands a user can add, remove, and otherwise edit the Registry from the command line.

If you want to import a Registry file from the command line you can use the regedit command and the name of the file you want to import. For example, if the name of the file was hope.reg you would type the below command at the prompt to import that file into the Registry.

regedit hope.reg

The file hope.reg could contain the commands necessary to add and remove Registry values. Below are some examples of Registry files to create entries, delete single entries as well as a complete folder. To create these files yourself copy the examples below into an empty .reg file or use notepad or the edit command to create a file using the commands shown below.

Note: Users running earlier versions of Windows may want to substitute Windows Registry Editor Version 5.00 with REGEDIT4.

The example below adds ComputerHope folder into the HKEY_LOCAL_MACHINE\Software directory with a string example that has a data value of data here.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\ComputerHope]
"example"="data here"

To delete a single entry within the Registry add a hyphen (minus) key after the equal sign. For example, if we wanted to delete our string value "example" we created with the above example we would create the below .reg file.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\ComputerHope]
"example"=-

Finally, to delete the folder and all its continents create a .reg file similar to the example below.

Windows Registry Editor Version 5.00

[-HKEY_LOCAL_MACHINE\SOFTWARE\ComputerHope]

Available regedit command switches and syntax that can be used.

REGEDIT [/L:system] [/R:user] [/C] [/R] [/E] [/S] [/C] filename [Registry_key]

/S The /s or -s regedit commands can be added to the command to suppress the confirmation box "Are you sure want to add the information in hope.reg to the Registry?" when running the command at the command line. For example, using the same command used earlier you can type: regedit /s hope.reg and have that Registry file immediately imported into the Registry.
/E Export the full Registry to a file. For example, typing: regedit /e full.reg would export the full Registry to the full.reg file.

This switch can also be used to export individual Registry keys. For example, typing: regedit /e software.reg "HKEY_LOCAL_MACHINE\Software" would export all the values in this folder to the software.reg file.

Note: This is not case sensitive.
/D Microsoft Windows 95, 98, and ME users can delete Registry keys using this switch. For example, typing: regedit /d "<Registry_key>" where Registry_key is replaced with the Registry key you want to delete would delete that Registry key.
/L:System Specify the location of the system.dat Registry file under Microsoft Windows 95, 98, and ME. For example, regedit /L:c:\windows\system.dat c:\system.dat
/R:user Specify the location of the user.dat Registry file under Microsoft Windows 95, 98, and ME. For example, regedit /L:c:\windows\system.dat c:\system.dat
/C Compress Registry file. This switch only works in Windows 98.

Additional information