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

      Export the Registry (all HKLM plus current user)
      REGEDIT /E pathname

      Export part of the Registry
      REGEDIT /E pathname "RegPath"

      Import a reg script
      REGEDIT pathname

      Silent import
      REGEDIT /S pathname

      Start the regedit GUI

      Open multiple copies of GUI (XP and 2003 only)
      REGEDIT -m

   /E : Export 

   /S : Silent Import

Under Windows NT 4 all registry scripts start with: REGEDIT4 (This version string will also work in all later versions of Windows.)

Add keys and values to the registry:

Create a text file like this:

Windows Registry Editor Version 5.00 


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

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

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

Delete keys and values from the registry:

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

Windows Registry Editor Version 5.00 

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

Windows Registry Editor Version 5.00 

Again double clicking this .reg file will delete the values specified, or you can use REGEDIT /s MyDeleteScript.REG

Compare the Registry of two machines

Windiff is your friend, this simple GUI utility from the resource kit will list all the differences.

Add Comments

Within a registry file, comments can be preceded by "; "
; Turn the NUMLOCK on at login
[HKEY_CURRENT_USER\Control Panel\Keyboard]

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:

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

“I never make stupid mistakes. Only very, very clever ones” - John Peel


REG - Read, Set or Delete registry keys and values
SET - Display, set, or remove Windows NT environment variables
SETX - Set environment variables permanently
WMIC REGISTRY - Set registry options through WMI
Powershell: Get-ItemProperty / Set-ItemProperty - Retrieve / save registry Keys
Q322756 - How to backup and edit the registry
Q310516 - How to add, modify, or delete registry subkeys and values
DuReg - Registry Size Estimator. (Win 2K ResKit)
Registry - Commonly tweaked user interface settings (XP)

© Copyright 1999-2015
Some rights reserved