Using REGEDIT to add, remove, and edit registry entries

REGEDIT.EXE [ /L:system /R:user ] [ /S ] importfile.REG

Export to a (.REG) file:
REGEDIT.EXE [ /L:system /R:user ] /E exportfile "registry_key"

Compress the registry (Windows 98 only):
REGEDIT.EXE [ /L:system /R:user ] /C

importfile.REG .REG file to be imported (or "merged")
exportfile File name the information should be written to
"registry_key" Registry key to be exported
e.g. "HKEY_CLASSES\ROOT\*\shell"
/S Silent, i.e. hide confirmation box when importing files
/E Export registry file
/L:system Specify the location of the system.dat to use
/R:user Specify the location of the user.dat to use
/C Compress [filename] (Windows 98 only)

REGEDIT is usually known as a GUI tool to search or edit the Windows registry.
I would not have mentioned it here, however, if it couldn't be used in unattended mode as well.
This page focuses on reading and editing the registry in unattended mode only.
(Microsoft's NT Workstation Resource Kit and NT Server Resource Kit come with REG.EXE, a utility that makes reading (or editing) NT's registry easier
It can read a single key and value directly, without the need for a temporary file.)

Adding and editing (importing) registry entries
Adding items to the registry requires a *.REG file:

REGEDIT /S addsome.REG
The /S switch is optional, it skips the message dialogs before and after the import of the *.REG file.

Removing registry entries
To remove an entire "tree" from the registry using REGEDIT and a .REG file, just add a minus sign before the tree name:



will remove the entire tree "DummyTree".

To remove an individual item from the registry, place the minus sign after the equal sign:


will remove the individual value "ValueToBeRemoved" from "DummyTree".

More info can be found at Regedit.com's Registry FAQ. How to remove an individual registry key or value using *.INF files and RUNDLL is explained here by Bill James.

Reading (exporting) from the registry
REGEDIT's /E switch can be used to export a registry key:

REGEDIT /E d:\path\filename.REG "HKEY_XXXX\Whatever Key"

This will write the registry key "HKEY_XXXX\Whatever Key" and its subkeys to a file named d:\path\filename.REG

TIP: Export a registry key to get an example of the exact required format.
"REGEDIT4" must be at the top followed by a blank line.
A blank line must be at the end of the file.
Multiple keys must be separated by a blank line (not the values, just new keys)


Post a Comment

Links to this post:

Create a Link

<< Home