Batch Script - Comparing Registry Keys


Advertisements

Comparing registry keys is done via the REG COMPARE command.

Syntax

REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/v ValueName] [Output] [/s]
REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/ve] [Output] [/s]

Wherein Output − /od (only differences) /os (only matches) /oa (all) /on (no output).

Example

@echo off
REG COMPARE HKEY_CURRENT_USER\Console HKEY_CURRENT_USER\Console\Test

The above program will compare all of the values between the registry keys HKEY_CURRENT_USER\Console & HKEY_CURRENT_USER\Console\Test.

Output

Result Compared: Identical
The operation completed successfully.

If there is a difference between the values in either registry key, it will be shown in the output as shown in the following result. The following output shows that the value ‘EnableColorSelection’ is extra I the registry key ‘HKEY_CURRENT_USER\Console’.

< Value: HKEY_CURRENT_USER\Console EnableColorSelection REG_DWORD 0x0
Result Compared: Different
The operation completed successfully.
batch_script_registry.htm
Advertisements