You can work with the Windows registry not only from the graphical snap-in, but also from the command line. The "reg" utility is used for this — it takes a command and a key or keys (a section or sections) as its arguments.
Moreover, it can work with remote computers.
Here's an example of running it:
C:\> reg QUERY HKLM\Software\Microsoft\ResKit
Supported commandsQUERY
Used to query a list of sections and/or keys.
C:\> reg QUERY HKLM\Software\Microsoft
Shows all keys and sections under the specified HKLM (HKEY_LOCAL_MACHINE) registry section.
C:\> reg QUERY \\192.168.0.1\HKLM\Software\Microsoft
The same thing, but for the remote computer 192.168.0.1
C:\> reg QUERY HKLM\Software\Microsoft /s
Shows all keys and sections for the specified section and all of its child sections.
ADD
Add a key to the specified registry section.
C:>\ reg ADD HKLM\Software\MySoftware /v MyNewKey /t REG_SZ /d "This is value"
where
- /v : Name of the key being added
- /t : Type of the key being added; one of: REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_DWORD, REG_QWORD, REG_BINARY, REG_NONE
- /d : value of the key being added
If the section specified as the parameter does not yet exist, it will be created automatically, including all of its nesting.
Add a subsection to the specified registry section (an empty section):
C:\> reg ADD HKLM\Software\MySoftware\AnotherFolder
DELETE
Deleting a section or a key.
Deleting a key in the specified section:
C:\> reg DELETE HKLM\Software\MySoftware /v MyKey
where after "/v" you specify the name of the key to delete.
Deleting a section:
C:\> reg DELETE HKLM\Software\MySoftware
In this example the entire "MySoftware" section, along with all its keys, will be deleted.
COPY
Copying a section:
C:\> reg COPY HKLM\Software\MySoftware1\Folder HKLM\Software\MySoftware2\Folder
Copying a section along with all its subsections:
C:\> reg COPY HKLM\Software\MySoftware1\Folder HKLM\Software\MySoftware2\Folder /s
SAVE
Saves the specified registry branch to a file.
C:\> reg SAVE HKLM\Software\MySoftware c:\folder\filename.hiv
RESTORE
Restores a registry branch from a file into the specified section.
C:\> reg RESTORE HKLM\Software\MySoftware c:\folder\filename.hiv
The file can be created using the SAVE command.
LOAD
Load a registry branch from a file into the specified section.
C:\> reg LOAD HKLM\Software\MySoftware c:\folder\filename.hiv
The file can be created using the SAVE command.
UNLOAD
Unload a registry branch that was loaded via LOAD.
C:\> reg UNLOAD HKLM\Software\MySoftware
COMPARE
Compares two registry branches (or specified keys within those branches).
Comparing branches:
C:\> reg COMPARE HKLM\Software\MySoftware HKCU\Software\MySoftware
Comparing keys:
C:\> reg COMPARE HKLM\Software\MySoftware HKCU\Software\MySoftware /v Keyname
You can also specify the output type by appending the corresponding switch to the end of the command:
- /oa : Output all differences and matches
- /od : Output only differences (default)
- /os : Output only matches
- /on : No output
EXPORT
Exports all values and subsections of the specified registry branch to a file (with absolute paths):
C:\> reg EXPORT HKLM\Software\MySoftware c:\folder\filename.reg
IMPORT
Imports all values and subsections from a registry file. The import uses the absolute paths stored in the .reg file, so the target registry branch is not specified.
C:\> reg IMPORT c:\folder\filename.reg
FLAGS
Sets, clears, or shows the current flags of a registry branch.
To show the current flags:
C:\> reg FLAGS HKLM\Software\MySoftware QUERY
To set all flags (DONT_VIRTUALIZE, DONT_SILENT_FAIL, RECURSE_FLAG):
C:\> reg FLAGS HKLM\Software\MySoftware SET DONT_VIRTUALIZE DONT_SILENT_FAIL RECURSE_FLAG
To set the DONT_VIRTUALIZE flag and clear the rest:
C:\> reg FLAGS HKLM\Software\MySoftware SET DONT_VIRTUALIZE
Remote managementSome commands support managing the registry on another machine (provided the current user you are working as has the appropriate access rights on that machine).
This is achieved by prefixing the section path with the computer name.
For example, suppose we have the section
HKLM\Software\MySoftware
then referring to this same section on computer 192.168.0.1 would look like this:
\\192.168.0.1\HKLM\Software\MySoftware
Commands that support remote management:
And, as always — a bit more — by reading reg's own help:
C:\> reg /?
Comments