Reference number: CH000848
How can I edit the registry from the command
prompt?
Question:
How can I edit the registry from the command prompt?
Answer:
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. Additional information about getting into Safe Mode can be
found on document CHSAFE.
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 our 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 wish to import a registry file from the command line you
can use the regedit command and the name of the file you wish 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 below examples into a 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 below example 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 below example.
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 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 wish 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:
- See our registry page for
additional help and information about the registry.
|