How to Get the List of Installed Software in a Batch Script
Auditing the software installed on a system is a fundamental task for system administrators, security professionals, and deployment scripters. You might need to generate a report of all installed applications, check for the presence of unauthorized software, or verify that a deployment was successful. While the "Apps & features" list is available in the GUI, this information can also be retrieved from a batch script.
This guide will teach you the modern, reliable, and recommended method for getting a comprehensive list of installed software by querying the Windows Registry. You will learn the correct REG QUERY command to use, how to check both 32-bit and 64-bit application locations, and why the older wmic product method should be avoided.
The Challenge: Where is the "Apps & features" List Stored?
There is no simple, single command to list all installed programs. The data that populates the "Apps & features" window is stored in the Windows Registry, in a specific key named Uninstall. To get a complete list, a script must query this key.
A crucial complication on 64-bit Windows is that there are two separate Uninstall locations that must be checked to get a full list:
- For 64-bit applications:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall - For 32-bit applications:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall
A reliable script must query both locations.
The Core Method (Recommended): Querying the Registry's "Uninstall" Key
The REG QUERY command is the standard tool for reading from the registry. We can use it to enumerate all the subkeys under the Uninstall key. Each subkey typically represents an installed application.
Command: REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" /s
/s: This switch tellsREG QUERYto list all subkeys and values sub-recursively. We can then parse this output to find theDisplayNameof each application.
The Legacy Method (To Avoid): wmic product
Many older guides recommend using the command wmic product get name. This method is obsolete and should be avoided.
- It is extremely slow. It can take several minutes to run, as it has to query and validate every Windows Installer package.
- It is incomplete. It only lists software that was installed using the Microsoft Installer (MSI) format, so it will miss a huge number of modern applications.
- It has a dangerous side effect. The query process can trigger a repair or reconfiguration of the applications it lists, which is highly undesirable.
For these reasons, the registry query method is the only professionally accepted way to do this from a script.
The Script: A Full Registry Query for Installed Software
This script queries both the 64-bit and 32-bit registry locations to find the DisplayName of every installed application.
This script must be run as an Administrator.
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO --- Listing Installed Software ---
ECHO This may take a moment...
ECHO.
SET "UninstallKey_64=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
SET "UninstallKey_32=HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
REM --- Create a temporary file to store the list ---
SET "OutputFile=%TEMP%\installed_software.txt"
IF EXIST "%OutputFile%" DEL "%OutputFile%"
REM --- Query both keys and find the DisplayName for each subkey ---
FOR %%K IN ("%UninstallKey_64%" "%UninstallKey_32%") DO (
FOR /F "delims=" %%S IN ('REG QUERY %%~K /s ^| FINDSTR /I /B " DisplayName"') DO (
REM Clean up the output from REG QUERY
SET "Line=%%S"
SET "DisplayName=!Line: DisplayName REG_SZ =!"
REM Filter out empty or irrelevant names
IF DEFINED DisplayName (
IF NOT "!DisplayName!"=="" ECHO !DisplayName! >> "%OutputFile%"
)
)
)
ECHO --- Installed Applications ---
TYPE "%OutputFile%"
DEL "%OutputFile%"
ENDLOCAL
PAUSE
How the script above works:
SETLOCAL ENABLEDELAYEDEXPANSION: This is essential for the string replacement logic inside the loop.FOR %%K IN (...): This outer loop iterates through our twoUninstallkey paths.FOR /F ... IN ('REG QUERY ...'): This is the main engine.REG QUERY %%~K /s: Recursively queries all the entries under the currentUninstallkey.^| FINDSTR /I /B " DisplayName": This filters the massive output fromREG QUERY. It finds only the lines that Begin (/B) with the literal stringDisplayName(note the leading spaces).
SET "DisplayName=!Line: DisplayName REG_SZ =!": This is a string substitution that removes the boilerplate text from theREG QUERYoutput, leaving just the application's name.ECHO !DisplayName! >> "%OutputFile%": The cleaned-up name is appended to a temporary output file.TYPE "%OutputFile%": At the end, the script displays the contents of the temporary file, which is our final, clean list.
Common Pitfalls and How to Solve Them
-
Administrator Rights: The
HKEY_LOCAL_MACHINE(HKLM) registry hive is a protected system location. The script will fail with access errors if it is not run with elevated privileges. Solution: Always run the script as an Administrator. -
32-bit vs. 64-bit: Forgetting to check the
WOW6432Nodepath is the most common mistake. This will cause your script to completely miss all 32-bit applications installed on a 64-bit system. Solution: Always query both keys. -
"Hidden" Applications: Some applications set a
SystemComponentvalue in their registry key, which hides them from the "Apps & features" list. The script above will still find and list these.
Practical Example: A Software Audit Report Script
This script adapts the core logic to create a timestamped CSV file, which is perfect for importing into a spreadsheet for auditing or record-keeping.
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET "ReportFile=%USERPROFILE%\Desktop\Software_Audit_%date:~-4%%date:~4,2%%date:~7,2%.csv"
ECHO "DisplayName","InstallLocation" > "%ReportFile%"
SET "KeysToQuery="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall""
FOR %%K IN (%KeysToQuery%) DO (
FOR /F "delims=" %%S IN ('REG QUERY %%~K /s ^| findstr /I /B " DisplayName"') DO (
SET "Line=%%S"
SET "DisplayName=!Line: DisplayName REG_SZ =!"
REM Get the InstallLocation for the current app
SET "InstallLocation="
FOR /F "tokens=2,*" %%A IN ('REG QUERY "%%~S" /v "InstallLocation" 2^>NUL') DO (
SET "InstallLocation=%%B"
)
IF DEFINED DisplayName ECHO "!DisplayName!","!InstallLocation!" >> "%ReportFile%"
)
)
ECHO [SUCCESS] Software audit report created at:
ECHO "%ReportFile%"
ENDLOCAL
Conclusion
Querying the Windows Registry is the definitive and most reliable method for getting a list of installed software from a batch script.
- The core command is
REG QUERY, targeted at the system'sUninstallkeys. - You must run the script as an Administrator.
- You must check both the 64-bit and 32-bit registry locations to get a complete list.
- Avoid the outdated and flawed
wmic productcommand.
By using REG QUERY and carefully parsing its output, you can create powerful and accurate software auditing tools with a simple batch script.