Regedit Command Line Switches
Although it is not mentioned in the documentation, Windows Registry Editor has a number of options for manipulating Windows registry via command line. Here is the syntax and usage examples.
Registry Exporting
- To export all registry contens to the file c:\all.reg, use the
/e
switch as follows:
regedit /E c:\all.reg
- To export a specific registry key to the file
file.reg
, use the /e switch as follows:
regedit /E file.reg <registry_key>
, for example
regedit /E c:\hklm_run.reg "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run"
will export the list of startup programs from the "Run" section.
Registry Importing
- Merge or import file.reg to a Registry:
regedit file.reg
- Create and replace an existing registry from a file file.reg:
regedit /C file.reg
Registry Deleting
Delete a registry key
- To delete a specific registry key from the registry:
Windows 10, 8, 7 You can create the .reg file and specify the minus sign before the key name to delete, here is the example file contents of c:\del.reg:
Windows Registry Editor Version 5.00
Now launch the Regedit using
[-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]regedit c:\del.reg
, and the key HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System will be removed from the system registry.Windows 95,98,ME Regedit has the
/D
switch, use it as follows:
regedit /D <registry_key>
, for example
regedit /D "HKEY_CLASSES_ROOT\CLSID\{834261E1-DD97-4177-853B-C907E5D5BD6E}"
will delete the entry of Trojan CWS
Delete a registry value
- To delete a specific registry value, specify the minus sign instead of a value in the .reg file:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
"CleanShutdown"=-
Other Switches
- For silent execution of the Regedit program, use the
/s
parameter. If/s
is specified, Regedit will suppress any informational dialog boxes and operate quietly, without asking for confirmation. - Windows 95,98,ME There are several command line switches for specifying location of User.dat (/L) and
user name (/R):
regedit /L:c:\windows\user.dat /e c:\test.reg