LKBEN11373: Howto query the registry from a cmd command line


This article has not been checked!

LKB | Created: 02/04/2020 | Version: 0 | Language: EN | Rating: 0 | Outdated: False | Marked for deletion: False

Author: Wim Peeters - Keskon GmbH & Co. KG


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!

About the Author

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 in different European countries and different European languages. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform where he is one of the most important contributors and the main developer.

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!