Import, export or delete registry settings from a text (.REG) file.
Syntax Export the Registry (all HKLM plus current user): REGEDIT /E pathname Export part of the Registry: REGEDIT /E pathname "RegPath" Export part of the Registry in ANSI mode: REGEDIT /A pathname "RegPath" (This is undocumented and will skip any unicode keys/values.) Import a reg script: REGEDIT pathname Silent import: REGEDIT /S pathname Start the regedit GUI: REGEDIT Open multiple copies of regedit: REGEDIT /m Key /E : Export /S : Silent Import
All registry scripts must start with a version string:
REGEDIT4 = Windows 98 or any later version of Windows.
Windows Registry Editor Version 5.00 = Windows 2000 or any later version of Windows.
Windows 2000 had the first support for Unicode in the registry.
Create a text file like this:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\SomeKey] "SomeStringValue"="Hello"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.
Create a reg file like this, notice the hyphen inside the first bracket
Windows Registry Editor Version 5.00 [-HKEY_CURRENT_USER\SomeKey]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.Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\SomeKey] "SomeStringValue"=-Again double click this .reg file to delete the values, or type REGEDIT /s MyFile.REG
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.
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
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.
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.
Within a registry file, comments are prefixed with a semicolon "; "
e.g.
;
; Set NUMLOCK at login
:
; 0 = Turn OFF at logon.
; 1 = Disable Num Lock.
; 2 = Turn ON at logon.
[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.
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
“Never test the depth of the river with both feet” ~ Ghanaian Proverb
REG - Read, Set or Delete registry keys and values.
SET - Display, set, or remove Windows environment variables.
SETX - Set environment variables permanently.
WMIC REGISTRY - Set registry options through WMI.
REGJUMP - Sysinternals utility to open Regedit at a specific registry path.
Q322756 - How to backup and edit the registry.
Q310516 - How to add, modify, or delete registry subkeys and values.
Equivalent PowerShell: Get-ItemProperty / Set-ItemProperty - Retrieve / save registry Keys.
Registry - Commonly tweaked user interface settings.