LKBEN11373: Howto query the registry from a cmd command line


Symptom

You need to find some reg values and process them from the commandline

Cause

none

Solution

Getting registry values from the command line can be done with the reg command. The tool cannot just query! For more help about these options you can use the following options:

  REG QUERY /?
  REG ADD /?
  REG DELETE /?
  REG COPY /?
  REG SAVE /?
  REG RESTORE /?
  REG LOAD /?
  REG UNLOAD /?
  REG COMPARE /?
  REG EXPORT /?
  REG IMPORT /?

Finding which software is installed on my machine:

reg query HKLM\\SOFTWARE

The output will look like:

...
HKEY_LOCAL_MACHINE\\SOFTWARE\\Macromedia
HKEY_LOCAL_MACHINE\\SOFTWARE\\McAfee
HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft
HKEY_LOCAL_MACHINE\\SOFTWARE\\Mozilla
...

If you would like to see the default values from the winlogon you can use:

reg query \"HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon\\\"|findstr /i \"Default\"

Please note the space in \"Windows NT\", that is why you need to quote your string.

You can use complex contructs like:

for /f \"tokens=*\" %i in (reg query HKLM\\SOFTWARE\\JavaSoft) do echo %i

Please note to exchange %i with %%i when it is used in a cmd and not on the commandline!

Disclaimer:

The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!

About the Author

Author: Wim Peeters - Keskon GmbH & Co. KG

Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.