How to edit the registry from the command line
Windows users can access and edit the Windows registry through the command line. Review the sections below for the version of Windows on your computer and information about registry edit commands and syntax.
If you're attempting to edit the registry from the command line because you're unable to get to normal Windows, try first booting to Windows Safe Mode. Then, run Regedit from Safe Mode.
To open Windows registry in the command prompt, press Windows key+R, type cmd, and press Enter. In the Command Prompt, type regedit and press Enter.
Microsoft Windows XP, Vista, 7, 8, 10, and 11 users
Microsoft Windows XP and later users can view, edit, and modify their registry from the Command Prompt application using the reg command. See the reg command page for additional information and examples.
Microsoft Windows 95, 98, Me, and 2000 users
The instructions in this section also work for later versions of Microsoft Windows.
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 containing the proper commands, a user can add, remove, and otherwise edit the registry from the command line.
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, type the following command.
Regedit hope.reg
The file hope.reg could contain the commands necessary to add and remove registry values. Below are examples of registry files to create entries, delete single entries, and a complete folder. To create these files yourself, copy the following examples into an empty .reg file or use notepad or the edit command to create a file using the following commands.
Users running earlier versions of Windows may want to substitute Windows Registry Editor Version 5.00 with REGEDIT4.
The following example adds a ComputerHope folder into the HKEY_LOCAL_MACHINE\Software directory with a string example and data value of data here.
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\ComputerHope] "example"="data here"
To delete a single entry in 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 following .reg file.
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\ComputerHope] "example"=-
To delete the folder and all its continents, create a .reg file similar to the following example.
Windows Registry Editor Version 5.00 [-HKEY_LOCAL_MACHINE\SOFTWARE\ComputerHope]
Regedit command syntax
REGEDIT [/L:system] [/R:user] [/C] [/R] [/E] [/S] [/C] FILE [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. This switch 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. |