Microsoft DOS reg command

Quick links

About reg
Availability
Syntax
Examples

About reg

Command line registry tool that enables you to change, display, update, and otherwise manipulate the registry from the prompt.

Availability

The reg.exe command is an external command that is available in the below Microsoft operating systems.

Windows XP
Windows Vista
Windows 7

Syntax

Windows Vista and later syntax
Windows XP and earlier syntax

Windows Vista and later syntax

REG Operation [Parameter List]

Operation [ QUERY | ADD | DELETE | COPY | SAVE | LOAD | UNLOAD | RESTORE | COMPARE | EXPORT | IMPORT | FLAGS ]

Return Code: (Except for REG COMPARE)

0 – Successful
1 – Failed

REG QUERY

REG QUERY KeyName [/v [ValueName] | /ve] [/s] [/f Data [/k] [/d] [/c] [/e]] [/t Type] [/z] [/se Separator] [/reg:32 | /reg:64]

KeyName

[\\Machine\]FullKey
Machine – Name of remote machine, omitting defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey – in the form of ROOTKEY\SubKey name

ROOTKEY – [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey – The full name of a registry key under the selected ROOTKEY

/v

Queries for a specific registry key values. If omitted, all values for the key are queried.

Argument to this switch can be optional only when specified along with /f switch. This specifies to search in valuenames only.

/ve Queries for the default value or empty value name (Default).
/s Queries all subkeys and values recursively (like dir /s).
/se Specifies the separator (length of 1 character only) in data string for REG_MULTI_SZ. Defaults to “” as the separator.
/f Specifies the data or pattern to be searched. Use double quotes if a string contains spaces. Default is “*”.
/k Specifies to search in key names only.
/d Specifies the search in data only.
/c Specifies that the search is case sensitive. The default search is case insensitive.
/e Specifies to return only exact matches. By default all the matches are returned.
/t

Specifies registry value data type.
Valid types are:
REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ,
REG_DWORD, REG_QWORD, REG_BINARY, REG_NONE
Defaults to all types.

/z Verbose: Shows the numeric equivalent for the type of the valuename.
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64

Specifies the key should be accessed using the 64-bit registry view.

Examples:

REG QUERY HKLM\Software\Microsoft\ResKit /v Version
Displays the value of the registry value Version

REG QUERY \\ABC\HKLM\Software\Microsoft\ResKit\Nt\Setup /s
Displays all subkeys and values under the registry key Setup on remote machine ABC

REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /se #
Displays all the subkeys and values with “#” as the seperator for all valuenames whose type is REG_MULTI_SZ.

REG QUERY HKLM /f SYSTEM /t REG_SZ /c /e
Displays Key, Value and Data with case sensitive and exact occurrences of “SYSTEM” under HKLM root for the data type REG_SZ

REG QUERY HKCU /f 0F /d /t REG_BINARY
Displays Key, Value and Data for the occurrences of “0F” in data under HKCU root for the data type REG_BINARY

REG QUERY HKLM\SOFTWARE /ve
Displays Value and Data for the empty value (Default) under HKLM\SOFTWARE

REG ADD

REG ADD KeyName [/v ValueName | /ve] [/t Type] [/s Separator] [/d Data] [/f] [/reg:32 | /reg:64]

KeyName

[\\Machine\]FullKey
Machine – Name of remote machine, omitting defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey – in the form of ROOTKEY\SubKey name

ROOTKEY – [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey – The full name of a registry key under the selected ROOTKEY

/v The value name, under the selected Key, to add.
/ve Queries for the default value or empty value name (Default).
/t RegKey data types [ REG_SZ | REG_MULTI_SZ | REG_EXPAND_SZ | REG_DWORD | REG_QWORD | REG_BINARY | REG_NONE ] If omitted, REG_SZ is assumed.
/s Specify one character that you use as the separator in your data string for REG_MULTI_SZ. If omitted, use “” as the separator.
/d The data to assign to the registry ValueName being added.
/f Force overwriting the existing registry entry without prompt.
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64

Specifies the key should be accessed using the 64-bit registry view.

Examples:

REG ADD \\ABC\HKLM\Software\MyCo
Adds a key HKLM\Software\MyCo on remote machine ABC

REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead
Adds a value (name: Data, type: REG_BINARY, data: fe340ead)

REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d faxmail
Adds a value (name: MRU, type: REG_MULTI_SZ, data: faxmail)

REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d ^%systemroot^%
Adds a value (name: Path, type: REG_EXPAND_SZ, data: %systemroot%)
Notice: Use the caret symbol ( ^ ) inside the expand string

REG DELETE

REG DELETE KeyName [/v ValueName | /ve | /va] [/f] [/reg:32 | /reg:64]

KeyName

[\\Machine\]FullKey
Machine – Name of remote machine, omitting defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey – in the form of ROOTKEY\SubKey name

ROOTKEY – [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey – The full name of a registry key under the selected ROOTKEY

ValueName The value name, under the selected Key, to delete. When omitted, all subkeys and values under the Key are deleted.
/ve delete the value of empty value name (Default).
/va delete all values under this key.
/f Forces the deletion without prompt.
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64

Specifies the key should be accessed using the 64-bit registry view.

Examples:

REG DELETE HKLM\Software\MyCo\MyApp\Timeout
Deletes the registry key Timeout and all its subkeys and values

REG DELETE \\ZODIAC\HKLM\Software\MyCo /v MTU
Deletes the registry value MTU under MyCo on ZODIAC

REG COPY

REG COPY KeyName1 KeyName2 [/s] [/f] [/reg:32 | /reg:64]

KeyName

[\\Machine\]FullKey
Machine – Name of remote machine, omitting defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey – in the form of ROOTKEY\SubKey name

ROOTKEY – [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey – The full name of a registry key under the selected ROOTKEY

/s Copies all subkeys and values.
/f Forces the copy without prompt.
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64

Specifies the key should be accessed using the 64-bit registry view.

Examples:

REG COPY HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp /s
Copies all subkeys and values under the key MyApp to the key SaveMyApp

REG COPY \\ZODIAC\HKLM\Software\MyCo HKLM\Software\MyCo1
Copies all values under the key MyCo on ZODIAC to the key MyCo1 on the current machine

REG SAVE

REG SAVE KeyName FileName [/y] [/reg:32 | /reg:64]

KeyName

[\\Machine\]FullKey
Machine – Name of remote machine, omitting defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey – in the form of ROOTKEY\SubKey name

ROOTKEY – [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey – The full name of a registry key under the selected ROOTKEY

/y Force overwriting the existing file without prompt.
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64

Specifies the key should be accessed using the 64-bit registry view.

Examples:

REG SAVE HKLM\Software\MyCo\MyApp AppBkUp.hiv
Saves the hive MyApp to the file AppBkUp.hiv in the current folder

REG LOAD

REG LOAD KeyName FileName [/reg:32 | /reg:64]

KeyName

[\\Machine\]FullKey
Machine – Name of remote machine, omitting defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey – in the form of ROOTKEY\SubKey name

ROOTKEY – [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey – The full name of a registry key under the selected ROOTKEY

FileName The name of the hive file to load. You must use REG SAVE to create this file.
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64

Specifies the key should be accessed using the 64-bit registry view.

Examples:

REG LOAD HKLM\TempHive TempHive.hiv
Loads the file TempHive.hiv to the Key HKLM\TempHive

REG UNLOAD

REG UNLOAD KeyName

KeyName

ROOTKEY\SubKey (local machine only)

ROOTKEY – [ HKLM | | HKU ]
SubKey – The key name of the hive to unload.

Examples:

REG UNLOAD HKLM\TempHive
Unloads the hive TempHive in HKLM

REG RESTORE

REG RESTORE KeyName FileName [/reg:32 | /reg:64]

KeyName

[\\Machine\]FullKey
Machine – Name of remote machine, omitting defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey – in the form of ROOTKEY\SubKey name

ROOTKEY – [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey – The full name of a registry key under the selected ROOTKEY

FileName The name of the hive file to restore. You must use REG SAVE to create this file.
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64

Specifies the key should be accessed using the 64-bit registry view.

Examples:

REG RESTORE HKLM\Software\Microsoft\ResKit NTRKBkUp.hiv
Restores the file NTRKBkUp.hiv overwriting the key ResKit

REG COMPARE

REG COMPARE KeyName1 KeyName2 [/v ValueName | /ve] [Output] [/s] [/reg:32 | /reg:64]

KeyName

[\\Machine\]FullKey
Machine – Name of remote machine, omitting defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey – in the form of ROOTKEY\SubKey name

ROOTKEY – [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey – The full name of a registry key under the selected ROOTKEY

ValueName The value name, under the selected Key, to compare. When omitted, all values under the Key are compared.
/ve Compare the value of empty value name (Default).
/s Compare all subkeys and values.
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64

Specifies the key should be accessed using the 64-bit registry view.

Output

[/oa | /od | /os | /on]
When omitted, output only differences.

/oa Output all of differences and matches.
/od Output only differences.
/os Output only matches.
/on No output.

Return Code:

0 – Successful, the result compared is identical
1 – Failed
2 – Successful, the result compared is different

Note:
The symbols at the front of each outputted line are defined as:
= means FullKey1 data is equal to FullKey2 data
< refers to FullKey1 data and is different than FullKey2 data
> refers to FullKey2 data and is different than Fullkey1 data

Examples:

REG COMPARE HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp
Compares all values under the key MyApp with SaveMyApp

REG COMPARE HKLM\Software\MyCo HKLM\Software\MyCo1 /v Version
Compares the value Version under the key MyCo and MyCo1

REG COMPARE \\ZODIAC\HKLM\Software\MyCo \\. /s
Compares all subkeys and values under HKLM\Software\MyCo on ZODIAC
with the same key on the current machine

REG EXPORT

REG EXPORT KeyName FileName [/y] [/reg:32 | /reg:64]

KeyName

[\\Machine\]FullKey
Machine – Name of remote machine, omitting defaults to the current machine. Only HKLM and HKU are available on remote machines.

FullKey – in the form of ROOTKEY\SubKey name

ROOTKEY – [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey – The full name of a registry key under the selected ROOTKEY

FileName The name of the disk file to export.
/y Force overwriting the existing file without prompt.
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64

Specifies the key should be accessed using the 64-bit registry view.

Examples:

REG EXPORT HKLM\Software\MyCo\MyApp AppBkUp.reg
Exports all subkeys and values of the key MyApp to the file AppBkUp.reg

REG IMPORT

REG IMPORT FileName [/reg:32 | /reg:64]

FileName The name of the disk file to import (local machine only).
/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64

Specifies the key should be accessed using the 64-bit registry view.

Examples:

REG IMPORT AppBkUp.reg
Imports registry entries from the file AppBkUp.reg

REG FLAGS

REG FLAGS KeyName [QUERY | SET [DONT_VIRTUALIZE] [DONT_SILENT_FAIL] [RECURSE_FLAG]] [/reg:32 | /reg:64]

KeyName

“HKLM\Software”[\SubKey] (Restricted to these keys on local machine only).
SubKey The full name of a registry key under HKLM\Software.
DONT_VIRTUALIZE DONT_SILENT_FAIL RECURSE_FLAG Used with SET; flags specified on the command line will be set, while those not specified will be cleared.

/reg:32 Specifies the key should be accessed using the 32-bit registry view.
/reg:64

Specifies the key should be accessed using the 64-bit registry view.

Examples:

REG FLAGS HKLM\Software\MyCo\MyApp QUERY
Displays the current flags of the key MyApp.

REG FLAGS HKLM\Software\MyCo\MyApp SET DONT_VIRTUALIZE /s
Sets the DONT_VIRTUALIZE flag (and clears DONT_SILENT_FAIL and RECURSE_FLAG) on MyApp and all its subkeys

Windows XP and earlier syntax

REG Operation [Parameter List]

Operation [ QUERY | ADD | DELETE | COPY | SAVE | LOAD | UNLOAD | RESTORE | COMPARE | EXPORT | IMPORT ]

Return Code: (Except of REG COMPARE)

0 – Successful
1 – Failed

REG QUERY

REG QUERY KeyName [/v ValueName | /ve] [/s]

KeyName [\Machine\]FullKey
Machine Name of remote machine, omitting defaults to the current machine Only HKLM and HKU are available on remote machines.
FullKey in the form of ROOTKEY\SubKey name ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ] SubKey – The full name of a registry key under the selected ROOTKEY
/v query for a specific registry key
ValueName The name, under the selected Key, to query if omitted, all values under the Key are queried.
/ve query for the default value or empty value name <no name>
/s queries all subkeys and values

REG ADD

REG ADD KeyName [/v ValueName | /ve] [/t type] [/s Separator] [/d Data] [/f]

KeyName [\\Machine\]FullKey
Machine Name of remote machine – omitting defaults to the current machine Only HKLM and HKU are available on remote machines.
FullKey ROOTKEY\SubKey ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ] SubKey The full name of a registry key under the selected ROOTKEY
/v The value name, under the selected Key, to add.
/ve adds an empty value name <no name> for the key.
/t RegKey data types
[ REG_SZ | REG_MULTI_SZ | REG_DWORD_BIG_ENDIAN | REG_DWORD | REG_BINARY | REG_DWORD_LITTLE_ENDIAN | REG_NONE | REG_EXPAND_SZ ]
If omitted, REG_SZ is assumed
/s Specify one character that you use as the separator in your data string for REG_MULTI_SZ. If omitted, use “” as the separator.
/d The data to assign to the registry ValueName being added.
/f Force overwriting the existing registry entry without prompt.

REG DELETE

REG DELETE KeyName [/v ValueName | /ve | /va] [/f]

KeyName [\\Machine\]FullKey
Machine Name of remote machine – omitting defaults to the current machine Only HKLM and HKU are available on remote machines.
FullKey ROOTKEY\SubKey
ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey The full name of a registry key under the selected ROOTKEY
ValueName The value name, under the selected Key, to delete When omitted, all subkeys and values under the Key are deleted.
/ve delete the value of empty value name <no name>
/va delete all values under this key
/f Forces the deletion without prompt

REG COPY

REG COPY KeyName1 KeyName2 [/s] [/f]

KeyName [\\Machine\]FullKey
Machine Name of remote machine – omitting defaults to the current machine Only HKLM and HKU are available on remote machines.
FullKey ROOTKEY\SubKey
ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey The full name of a registry key under the selected ROOTKEY
/s Copies all subkeys and values
/f Forces the copy without prompt

REG SAVE

REG SAVE KeyName FileName

KeyName ROOTKEY\SubKey
ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey The full name of a registry key under the selected ROOTKEY
FileName The name of the disk file to save. If no path is specified, the file is created in the current folder of the calling process.

REG RESTORE

REG RESTORE KeyName FileName

KeyName ROOTKEY\SubKey (local machine only)
ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey The full name of a registry key to restore the hive file into.
Overwriting the existing key’s values and subkeys.
FileName The name of the hive file to restore. You must use REG SAVE to create this file.

REG LOAD

REG LOAD KeyName FileName

KeyName ROOTKEY\SubKey (local machine only)
ROOTKEY [ HKLM | HKU ]
SubKey The key name to load the hive file into. Creating a new key.
FileName The name of the hive file to load. You must use REG SAVE to create this file.

REG UNLOAD

REG UNLOAD KeyName

KeyName ROOTKEY\SubKey (local machine only)
ROOTKEY [ HKLM | HKU ]
SubKey The key name of the hive to unload.

REG COMPARE

REG COMPARE KeyName1 KeyName2 [/v ValueName | /ve] [Output] [/s] 

KeyName [\\Machine\]FullKey
Machine Name of remote machine – omitting defaults to the current machine.
Only HKLM and HKU are available on remote machines
FullKey ROOTKEY\SubKey
If FullKey2 is not specified, FullKey2 is the same as FullKey1
ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey The full name of a registry key under the selected ROOTKEY
ValueName The value name, under the selected Key, to compare
When omitted, all values under the Key are compared
/ve compare the value of empty value name <no name>
/s Compare all subkeys and values
Output [/oa | /od | /os | /on]
When omitted, output only differences

/oa Output all of differences and matches
/od Output only differences
/os Output only matches
/on No output

Return Code:

0 – Successful, the result compared is identical
1 – Failed
2 – Successful, the result compared is different

REG EXPORT

REG EXPORT KeyName FileName

Keyname ROOTKEY\SubKey (local machine only)
ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ]
SubKey The full name of a registry key under the selected ROOTKEY
FileName The name of the disk file to export.

REG IMPORT

REG IMPORT FileName

FileName The name of the disk file to import (local machine only).

Examples

Tip: Each of the examples below are the examples Microsoft has listed in each of the command help menus available through the /? switch on this command. See the above syntax for a full listing of all examples that relate to each of the available options.

Reg query examples:

REG QUERY HKLM\Software\Microsoft\ResKit /v Version

Displays the value of the registry value Version

REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /s

Displays all subkeys and values under the registry key Setup

Reg add Examples:

REG ADD \\ABC\HKLM\Software\MyCo

Adds a key HKLM\Software\MyCo on remote machine ABC

REG ADD HKLM\Software\MyCo /v Data /t REG_BINARY /d fe340ead

Adds a value (name: Data, type: REG_BINARY, data: fe340ead)

REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d faxmail

Adds a value (name: MRU, type: REG_MUTLI_SZ, data: faxmail)

REG ADD HKLM\Software\MyCo /v Path /t REG_EXPAND_SZ /d %%systemroot%%

Adds a value (name: Path, type: REG_EXPAND_SZ, data: %systemroot%)
Notice: Use the double percentage ( %% ) inside the expand string

Reg delete examples:

REG DELETE HKLM\Software\MyCo\MyApp\Timeout

Deletes the registry key Timeout and its all subkeys and values

REG DELETE \\ZODIAC\HKLM\Software\MyCo /v MTU

Deletes the registry value MTU under MyCo on ZODIAC

Reg copy examples:

REG COPY HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp /s

Copies all subkeys and values under the key MyApp to the key SaveMyApp

REG COPY \\ZODIAC\HKLM\Software\MyCo HKLM\Software\MyCo1

Copies all values under the key MyCo on ZODIAC to the key MyCo1
on the current machine

Reg save examples:

REG SAVE HKLM\Software\MyCo\MyApp AppBkUp.hiv

Saves the hive MyApp to the file AppBkUp.hiv in the current folder

Reg restore examples:

REG RESTORE HKLM\Software\Microsoft\ResKit NTRKBkUp.hiv

Restores the file NTRKBkUp.hiv overwriting the key ResKit

Reg load examples:

REG LOAD HKLM\TempHive TempHive.hiv

Loads the file TempHive.hiv to the Key HKLM\TempHive

Reg unload examples:

REG UNLOAD HKLM\TempHive

Unloads the hive TempHive in HKLM

Reg compare examples:

REG COMPARE HKLM\Software\MyCo\MyApp HKLM\Software\MyCo\SaveMyApp

Compares all values under the key MyApp with SaveMyApp

REG COMPARE HKLM\Software\MyCo HKLM\Software\MyCo1 /v Version

Compares the value Version under the key MyCo and MyCo1

REG COMPARE \\ZODIAC\HKLM\Software\MyCo \\. /s

Compares all subkeys and values under HKLM\Software\MyCo on ZODIAC
with the same key on the current machine

Reg export examples:

REG EXPORT HKLM\Software\MyCo\MyApp AppBkUp.reg

Exports all subkeys and values of the key MyApp to the file AppBkUp.reg

Reg import examples:

REG IMPORT AppBkUp.reg

Imports registry entrys from the file AppBkUp.reg