REGEDIT – Windows CMD Command

Import, export or delete registry settings from a text (.REG) file.

All registry scripts start with a version string:
REGEDIT4 for ANSI/ASCII text strings – Windows 98 and Windows NT 4.0 (or any later versions of Windows.)
“Windows Registry Editor Version 5.00” for Unicode – Windows 2000, XP (or later)

Add keys and values to the registry:

Create a text file like this:

Note the registry file should contain a blank line at the bottom of the file.

The registry file must use full names for registry hives (HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER, etc.)
not short abbreviations (HKLM, HKCU, etc.).

When double clicking this .reg file the key and value will be added.
Alternatively run REGEDIT Myfile.REG from the command line.

Delete keys and values from the registry:

Create a reg file like this, notice the hyphen inside the first bracket

When double clicking this .reg file the key “SomeKey” will be deleted along with all string, binary or Dword values in that key.

If you want to just delete values, leaving the key in place, set the value you want to delete = to a hyphen
e.g.

Again double click this .reg file to delete the values, or type REGEDIT /s MyFile.REG

Elevation

Unlike REG.exe, REGEDIT will normally require elevation even when adding an item to HKCU,
after a sucessful elevation REGEDIT will give access to the whole registry, see elevation for more options.

Export a registry key to a text (.REG) file

regedit /e export.reg HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Audio

Export the same key in ANSI text format:
regedit /A ansi.reg HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Audio

Compare the Registry of two machines

Opening multiple copies of Regedit.exe (with /m) is useful for comparing keys between two registry hives or between two different computers (File, connect network registry) Press F5 to refresh the view.

Windiff is a useful alternative, this GUI utility from the resource kit will list all the differences.

Drag and Drop

The Regedit GUI supports drag and drop of .reg files. This is mostly useful when connected to a remote registry allowing you to apply a .reg file to a remote machine.

Add Comments

Within a registry file, comments are prefixed with a semicolon “; “
e.g.
;
; Turn the NUMLOCK on at login
;
[HKEY_CURRENT_USER\Control Panel\Keyboard]
“InitialKeyboardIndicators”=”2”

Batch files will ignore any semicolons before a command, so this can be used to create a self-contained registry script.

Open the regedit GUI at a given Key

Regedit remembers the last registry key that was opened from the last time it was running. This is stored in the registry under:
HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit
[LastKey]
We can set the LastKey value property from the command line with a REG ADD command.

Set “_mykey=HKEY_CURRENT_USER\Software\Microsoft”
REG ADD “HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit” /v “LastKey” /d “%_mykey%” /f
Start /b regedit

To activate registry changes in HKEY_CURRENT_USER without logging off:
RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True

You may also like...

1 Response

  1. zortilonrel says:

    As I web site possessor I believe the content material here is rattling excellent , appreciate it for your efforts. You should keep it up forever! Good Luck.

Leave a Reply

Your email address will not be published. Required fields are marked *