Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Reg

Updated: January 21, 2005

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

Reg

Performs add, change, import, export and other operations on registry subkey information and values in registry entries.

The reg commands include:

reg add

reg compare

reg copy

reg delete

reg export

reg import

reg load

reg query

reg restore

reg save

reg unload

reg add

Adds a new subkey or entry to the registry.

Syntax

reg add KeyName [{/v ValueName | /ve}] [/t DataType] [/s Separator] [/d Data] [/f]

Parameters
KeyName
Specifies the full path of the subkey or entry to be added. For specifying remote computers, include the computer name (in the format \\ComputerName\) as part of the KeyName. Omitting \\ComputerName\ causes the operation to default to the local computer. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are HKLM and HKU.

/v ValueName
Specifies the name of the registry entry to be added under the specified subkey.

/ve
Specifies that the registry entry that is added to the registry has a null value.

/t Type
Specifies the type for the registry entry. Type must be one of the following:

REG_SZ

REG_MULTI_SZ

REG_DWORD_BIG_ENDIAN

REG_DWORD

REG_BINARY

REG_DWORD_LITTLE_ENDIAN

REG_LINK

REG_FULL_RESOURCE_DESCRIPTOR

REG_EXPAND_SZ

/s Separator
Specifies the character to be used to separate multiple instances of data when the REG_MULTI_SZ data type is specified and more than one entry needs to be listed. If not specified, the default separator is "\0".

/d Data
Specifies the data for the new registry entry.

/f
Adds the registry entry without prompting for confirmation.

/?
Displays help for reg add at the command prompt.

Remarks
  • Subtrees cannot be added with this operation. This version of Reg does not ask for confirmation when adding a subkey.

  • The following table lists the return values for the reg add operation.

     

    Value Description

    0

    Success

    1

    Failure

  • For key types of REG_EXPAND_SZ, use the caret symbol ( ^ ) with "%" inside the /d parameter.

Examples

To add the key HKLM\Software\MyCo on remote machine ABC, type:

REG ADD \\ABC\HKLM\Software\MyCo

To add a registry entry to HKLM\Software\MyCo with the options of ValueName: Data, Type: REG_BINARY, and ValueData: fe340ead, type:

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

To add a multivalued registry entry to HKLM\Software\MyCo with the options of ValueName: MRU, DataType: REG_MULTI_SZ, and ValueData: fax\0mail\0\0, type:

REG ADD HKLM\Software\MyCo /v MRU /t REG_MULTI_SZ /d fax\0mail\0\0

To add an expanded registry entry to HKLM\Software\MyCo with the options of ValueName: Path, DataType: REG_EXPAND_SZ, and ValueData: %systemroot%, type:

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

reg compare

Compares specified registry subkeys or entries.

Syntax

reg compare KeyName1 KeyName2 [{/v ValueName | /ve}] [{/oa | /od | /os | on}] [/s]

Parameters
KeyName1
Specifies the full path of the first subkey to be compared. For specifying remote computers, include the computer name (in the format \\ComputerName\) as part of the KeyName. Omitting \\ComputerName\ causes the operation to default to the local computer. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are HKLM and HKU.

KeyName2
Specifies the full path of the second subkey to be compared. For specifying remote computers, include the computer name (in the format \\ComputerName\) as part of the KeyName. Omitting \\ComputerName\ causes the operation to default to the local computer. Specifying only the computer name in KeyName2 causes the operation to use the path to the subkey specified in KeyName1. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are HKLM and HKU.

/v ValueName
Specifies the value name under the subkey to compare.

/ve
Specifies that only entries that have a value name of null should be compared.

[{/oa | /od | /os | on}]
Specifies how to display the results of the compare operation. The default is /od. The following table lists each of the options.

 

Value Description

/oa

Specifies that all differences and matches are displayed. By default, only the differences are listed.

/od

Specifies that only differences are displayed. This is the default behavior.

/os

Specifies that only matches are displayed. By default, only the differences will be listed.

/on

Specifies that nothing is displayed. By default, only the differences will be listed.

/s
Compares all subkeys and entries recursively.

/?
Displays help for reg compare at the command prompt.

Remarks
  • The following table lists the return values for reg compare.

     

    Value Description

    0

    The comparison is successful and the result is identical.

    1

    The comparison failed.

    2

    The comparison is successful and differences were found.

  • The following table lists the symbols displayed in the results.

     

    Symbol Description

    =

    KeyName1 data is equal to KeyName2 data

    <

    KeyName1 data is less than KeyName2 data

    >

    KeyName1 data and is greater than KeyName2 data

Examples

To compare all values under the key MyApp with all values under the key SaveMyApp, type:

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

To compare the value for Version under the key MyCo and the value for Version under the key MyCo1, type:

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

To compare all subkeys and values under HKLM\Software\MyCo on the machine ZODIAC with all subkeys and values under HKLM\Software\MyCo on the current machine, type:

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

reg copy

Copies a registry entry to a specified location in the local or remote computer.

Syntax

reg copy KeyName1 KeyName2 [/s] [/f]

Parameters
KeyName1
Specifies the full path of the subkey to copy. For specifying remote computers, include the computer name (in the format \\ComputerName\) as part of the KeyName. Omitting \\ComputerName\ causes the operation to default to the local computer. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are HKLM and HKU.

KeyName2
Specifies the full path of the subkey destination. For specifying remote computers, include the computer name (in the format \\ComputerName\) as part of the KeyName. Omitting \\ComputerName\ causes the operation to default to the local computer. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are HKLM and HKU.

/s
Copies all subkeys and entries under the specified subkey.

/f
Copies the subkey without prompting for confirmation.

/?
Displays help for reg copy at the command prompt.

Remarks
  • Reg does not ask for confirmation when copying a subkey.

  • The following table lists the return values for the reg copy operation.

     

    Value Description

    0

    Success

    1

    Failure

Examples

To copy all subkeys and values under the key MyApp to the key SaveMyApp, type:

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

To copy all values under the key MyCo on the machine ZODIAC to the key MyCo1 on the current machine, type:

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

reg delete

Deletes a subkey or entries from the registry.

Syntax

Reg delete KeyName [{/v ValueName | /ve | /va}] [/f]

Parameters
KeyName
Specifies the full path of the subkey or entry to be deleted. For specifying remote computers, include the computer name (in the format \\ComputerName\) as part of the KeyName. Omitting \\ComputerName\ causes the operation to default to the local computer. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are HKLM and HKU.

/v ValueName
Deletes a specific entry under the subkey. If no entry is specified, then all entries and subkeys under the subkey will be deleted.

/ve
Specifies that only entries that have no value will be deleted.

/va
Deletes all entries under the specified subkey. Subkeys under the specified subkey are not deleted with this parameter.

/f
Deletes the existing registry subkey or entry without asking for confirmation.

/?
Displays help for reg delete at the command prompt.

Remarks
  • The following table lists the return values for the reg delete operation.

     

    Value Description

    0

    Success

    1

    Failure

Examples

To delete the registry key Timeout and its all subkeys and values, type:

REG DELETE HKLM\Software\MyCo\MyApp\Timeout

To delete the registry value MTU under HKLM\Software\MyCo on the machine ZODIAC, type:

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

reg export

Copies the specified subkeys, entries, and values of the local computer into a file for transfer to other servers.

Syntax

Reg export KeyName FileName [/y]

Parameters
KeyName
Specifies the full path of the subkey. The export operation works only with the local computer. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC.

FileName
Specifies the name and path of the file to be created during the operation. The file must have a .reg extension.

/y
Overwrites any existing file with the name FileName without prompting for confirmation.

/?
Displays help for reg export at the command prompt.

Remarks
  • The following table lists the return values for the reg export operation.

     

    Value Description

    0

    Success

    1

    Failure

Examples

To export the contents of all subkeys and values of the key MyApp to the file AppBkUp.reg, type:

reg export HKLM\Software\MyCo\MyApp AppBkUp.reg

reg import

Copies the contents of a file containing exported registry subkeys, entries, and values into the registry of the local computer.

Syntax

Reg import FileName

Parameters
FileName
Specifies the name and path of the file whose contents will be copied into the registry of the local computer. This file must be created beforehand using reg export.

/?
Displays help for reg import at the command prompt.

Remarks
  • The following table lists the return values for the reg import operation.

     

    Value Description

    0

    Success

    1

    Failure

Examples

To import registry entries from the file named AppBkUp.reg, type:

reg import AppBkUp.reg

reg load

Writes saved subkeys and entries into a different subkey in the registry. Intended for use with temporary files used for troubleshooting or editing registry entries.

Syntax

reg load KeyName FileName

Parameters
KeyName
Specifies the full path of the subkey to be loaded. For specifying remote computers, include the computer name (in the format \\ComputerName\) as part of the KeyName. Omitting \\ComputerName\ causes the operation to default to the local computer. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are HKLM and HKU.

FileName
Specifies the name and path of the file to be loaded. This file must be created beforehand with the reg save operation using a .hiv extension.

/?
Displays help for reg load at the command prompt.

Remarks
  • The following table lists the return values for the reg load operation.

     

    Value Description

    0

    Success

    1

    Failure

Examples

To load the file named TempHive.hiv to the key HKLM\TempHive, type:

REG LOAD HKLM\TempHive TempHive.hiv

reg quer#

Returns a list of the next tier of subkeys and entries located under a specified subkey in the registry.

Syntax

reg query KeyName [{/v ValueName | /ve}] [/s] [/se Separator] [/f Data] [{/k | /d}] [/c] [/e] [/t Type] [/z]

Parameters
KeyName
Specifies the full path of the subkey. For specifying remote computers, include the computer name (in the format \\ComputerName\) as part of the KeyName. Omitting \\ComputerName\ causes the operation to default to the local computer. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are HKLM and HKU.

/v ValueName
Specifies the registry value name to be queried. If omitted, all value names for KeyName are returned. ValueName for this parameter is optional if the /f option is also used.

/ve
Queries for value names that are empty.

/s
Specifies to query all subkeys and value names recursively.

/se Separator
Specifies the single value separator for which to search in value names of type REG_MULTI_SZ. If Separator is not specified, "\0" is used.

/f Data
Specifies the data or pattern for which to search. Use double quotes if a string contains spaces. If not specified, a wildcard ("*") is used as the search pattern.

/k
Specifies to search in key names only.

/d
Specifies to search in data only.

/c
Specifies that the query is case sensitive. By default, queries are not case sensitive.

/e
Specifies to return only exact matches. By default, all the matches are returned.

/t Type
Specifies registry types to search. Valid types are: REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, REG_DWORD, REG_BINARY, REG_NONE. If not specified, all types are searched.

/z
Specifies to include the numeric equivalent for the registry type in search results.

/?
Displays help for reg query at the command prompt.

Remarks
  • The following table lists the return values for the reg query operation.

     

    Value Description

    0

    Success

    1

    Failure

Examples

To display the value of the name value Version in the HKLM\Software\Microsoft\ResKit key, type:

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

To display all subkeys and values under the key HKLM\Software\Microsoft\ResKit\Nt\Setup on remote machine ABC, type:

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

To display all the subkeys and values of type REG_MULTI_SZ using "#" as the separator, type:

REG QUERY HKLM\Software\Microsoft\ResKit\Nt\Setup /se #

To display the key, value and data for exact and case sensitive matches of "SYSTEM" under the HKLM root of data type REG_SZ, type:

REG QUERY HKLM /f SYSTEM /t REG_SZ /c /e

To display the key, value and data for matches of "0F" in data under the HKCU root key of data type REG_BINARY.

REG QUERY HKCU /f 0F /d /t REG_BINARY

TO display the value and data for value names of null (Default) under HKLM\SOFTWARE, type:

REG QUERY HKLM\SOFTWARE /ve

reg restore

Writes saved subkeys and entries back to the registry.

Syntax

Reg restore KeyName FileName

Parameters
KeyName
Specifies the full path of the subkey to be restored. The restore operation works only with the local computer. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC.

FileName
Specifies the name and path of the file that whose contents be written into the registry. This file must be created beforehand with the reg save operation using a .hiv extension.

/?
Displays help for reg restore at the command prompt.

Remarks
  • Before editing any registry entries, save the parent subkey with the reg save operation. If the edit fails, restore the original subkey with the reg restore operation.

  • The following table lists the return values for the reg restore operation.

     

    Value Description

    0

    Success

    1

    Failure

Examples

To restore the file named NTRKBkUp.hiv into the key HKLM\Software\Microsoft\ResKit, overwriting the existing contents of the key, type:

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

reg save

Saves a copy of specified subkeys, entries, and values of the registry in a specified file.

Syntax

reg save KeyName FileName [/y]

Parameters
KeyName
Specifies the full path of the subkey. For specifying remote computers, include the computer name (in the format \\ComputerName\) as part of the KeyName. Omitting \\ComputerName\ causes the operation to default to the local computer. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are HKLM and HKU.

FileName
Specifies the name and path of the file that is created. If no path is specified, then the current path is used.

/y
Overwrite any existing file with a name of FileName without prompting for confirmation.

/?
Displays help for reg save at the command prompt.

Remarks
  • The following table lists the return values for the reg save operation.

     

    Value Description

    0

    Success

    1

    Failure

  • Before editing any registry entries, save the parent subkey with the reg save operation. If the edit fails, restore the original subkey with the reg restore operation.

Examples

To save the hiveMyApp into the current folder as a file named AppBkUp.hiv, type:

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

reg unload

Removes a section of the registry that was loaded using the reg load operation.

Syntax

reg unload KeyName

Parameters
KeyName
Specifies the full path of the subkey to be unloaded. For specifying remote computers, include the computer name (in the format \\ComputerName\) as part of the KeyName. Omitting \\ComputerName\ causes the operation to default to the local computer. The KeyName must include a valid root key. Valid root keys are HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are HKLM and HKU.

/?
Displays help for reg unload at the command prompt.

Remarks
  • The following table lists the return values for the reg unload operation.

     

    Value Description

    0

    Success

    1

    Failure

Examples

To unload the hive TempHive in HKLM, type:

REG UNLOAD HKLM\TempHive

Caution

  • Do not edit the registry directly unless you have no alternative. The registry editor bypasses standard safeguards, allowing settings that can degrade performance, damage your system, or even require you to reinstall Windows. You can safely alter most registry settings by using the programs in Control Panel or Microsoft Management Console (MMC). If you must edit the registry directly, back it up first. For more information, see Related Topics.

Remarks
  • Some operations allow the viewing or configuration of registry entries on local or remote computers, while others allow only the configuration of local computers. Also, using reg to configure the registry of remote computer limits the parameters that you can use in some operations. Check the syntax and parameters for each operation to verify that they can be used on remote computers.

Formatting legend

 

Format Meaning

Italic

Information that the user must supply

Bold

Elements that the user must type exactly as shown

Ellipsis (...)

Parameter that can be repeated several times in a command line

Between brackets ([])

Optional items

Between braces ({}); choices separated by pipe (|). Example: {even|odd}

Set of choices from which the user must choose only one

Courier font

Code or program output

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.