Reading NT's Registry with REG QUERY

The Microsoft ® Windows NT ® Server 4.0 Resource Kit contains, among many others, REG.EXE.

This tool can read and write Windows NT's registry.

The syntax for querying the registry is shown below:

Command-line registry manipulation utility version 1.00.
Copyright Microsoft Corporation 1997.  All rights reserved.

REG QUERY RegistyPath [\\Machine] [/S]

  RegistryPath	[ROOTKEY\]Key[\ValueName]
    ROOTKEY	[ HKLM | HKCU | HKCR | HKU | HKCC ]
           	Optional.  When omitted HKLM is assumed.
    Key    	The full name of a registry key under the selected ROOTKEY.
    ValueName	The value, under the selected Key, to query.
             	Optional.  When omitted all keys and values under the Key
             	are listed.
  Machine	Name of remote machine - omitting defaults to current machine.
         	Only HKLM and HKU are available on remote machines.
  /S, /s 	Queries all subkeys.

Examples:

  REG QUERY HKLM\Software\Microsoft\ResKit\Setup\InstallDir
  Displays the value of the InstallDir registry entry.

  REG QUERY HKLM\Software\Microsoft\ResKit\Setup /S
  Displays all keys and values under the Setup sub-key.

View this sample batch file that uses REG QUERY to get the Country setting from the registry.

 

Windows 2000

In Windows 2000, REG.EXE version 2.0 was added as a additional tool on the CD-ROM. It has to be installed manually, though (on the CD-ROM run "\SUPPORT\TOOLS\SETUP.EXE").
As of Windows XP, REG.EXE version 3.0 is a native command.
Note that there was a slight modification of the syntax:

Registry Console Tool For Windows 2000 - version 2.0
Copyright (C) Microsoft Corp. 1981-1999.  All rights reserved

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  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 query
             When omitted, all values under the Key are queried
  /ve        query the empty value name <no name>
  /s         queries all subkeys and values

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

IEVer.bat is an example of a batch file capable of using any version of REG.EXE.
It has been tested in Windows 2000 Professional only, however.


visitors can't be wrong... can they?

page last uploaded: 6 April 2009, 00:02