Skip to main content

Batch Script Comparing Registry Keys

Comparing Registry Keys

Comparing registry keys is done via the reg compare command.

Syntax
reg compare <keyname1> <keyname2> [{/v Valuename | /ve}] [{/oa | /od | /os | on}] [/s]

where:

  • <keyname1> specifies the full path of the subkey or entry to be added.
    • To specify a remote computer, 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 for the local computer are: HKLM, HKCU, HKCR, HKU, and HKCC. If a remote computer is specified, valid root keys are: HKLM and HKU.
    • If the registry key name contains a space, enclose the key name in quotes.
  • <keyname2> specifies the full path of the second subkey to be compared. It follows the same rules of <keyname1>.
  • /v <Valuename> specifies the value name to compare under the subkey.
  • /ve specifies that only entries that have a value name of null should be compared.
  • /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 are listed.
  • /on specifies that nothing is displayed. By default, only the differences are listed.
  • /s compares all subkeys and entries recursively.
  • /? displays help at the command prompt.

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 the Version under the key MyCo and the value for the 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 computer named ZODIAC, with all subkeys and values under HKLM\Software\MyCo on the local computer, type:

reg compare \\ZODIAC\HKLM\Software\MyCo \\. /s