@ECHO OFF IF NOT "%~3"=="" GOTO Syntax FOR %%A IN (%*) DO ( IF "%%~A"=="/?" GOTO Syntax ) SETLOCAL ENABLEDELAYEDEXPANSION :: Defaults SET Pattern=".*" SET Format=List SET SwitchCount=0 :: Parse command line FOR %%A IN (%*) DO ( SET Argument=%%A IF "!Argument:~0,1!"=="/" ( IF !SwitchCount! GTR 0 GOTO Syntax IF /I "%%A"=="/A" ( SET Format=Aligned SET UseSeparator=0 ) IF /I "%%A"=="/S" ( SET Format=Aligned SET UseSeparator=1 ) IF /I "%%A"=="/T" ( SET Format=TabDelimited ) IF "!Format!"=="List" GOTO Syntax SET /A SwitchCount += 1 ) ELSE ( IF NOT "!Pattern!"==".*" GOTO Syntax SET Pattern="%%~A" ) ) :: Prepare Aligned output IF "%Format%"=="Aligned" ( SET Width=0 FOR /F "skip=1 tokens=2" %%A IN ('MODE CON ^| MORE /E +2 ^| FIND /V "-"') DO ( IF "!Width!"=="0" SET Width=%%A ) SET Col2Width=25 SET /A Col1Width = !Width! - !Col2Width! - 2 SET WhiteLine= FOR /L %%W IN (0,1,!Width!) DO (SET WhiteLine= !WhiteLine!) IF "%UseSeparator%"=="1" ( REM Create a line of hyphens almost as wide as the console SET Separator= FOR /L %%W IN (3,1,!Width!) DO (SET Separator=-!Separator!) ) ) :: Iterate through the registry and add entries to the list FOR %%A IN (SOFTWARE SOFTWARE\Wow6432Node) DO ( FOR /F "tokens=*" %%B IN ('REG Query HKEY_LOCAL_MACHINE\%%A\Microsoft\Windows\CurrentVersion\Uninstall 2^>NUL ^| FIND /I "HKEY_LOCAL_MACHINE"') DO ( REM Check and display each valid result CALL :AddToList "%%~B" ) ) :: Iterate through the (sorted) list and display entries in the requested format FOR /F "tokens=1* delims==" %%A IN ('SET _DisplayName.') DO ( FOR /F "tokens=1* delims=." %%C IN ("%%~A") DO ( CALL :Display "%%~D" "%%~B" ) ) :: In case of Aligned output add a closing separaror line IF "%Format%"=="Aligned" IF "%UseSeparator%"=="1" ECHO.%Separator% ENDLOCAL GOTO:EOF :AddToList :: Read DisplayName and DisplayVersion values FOR %%C IN (DisplayName DisplayVersion) DO ( SET %%C= FOR /F "tokens=1,2*" %%D IN ('REG Query "%~1" /v "%%~C" 2^>NUL ^| FIND /I "%%~C"') DO SET %%D=%%~F ) :: Abort if either value is empty IF "%DisplayName%"=="" GOTO:EOF IF "%DisplayVersion%"=="" GOTO:EOF :: Abort if the DisplayName does not match the regex pattern ECHO.%DisplayName%| FINDSTR /R /I /C:%Pattern% >NUL || GOTO:EOF SET "_DisplayName.%DisplayName%=%DisplayVersion%" IF /I "%Format%"=="List" SET "_Regkey.%DisplayName%=%~1" GOTO:EOF :Aligned :: Align the columns SET Displayname=%Displayname%%WhiteLine% SET DisplayVersion=%WhiteLine%%DisplayVersion% SET Displayname=!Displayname:~0,%Col1Width%! SET DisplayVersion=!DisplayVersion:~-%Col2Width%! :: Insert a separator line if requested by /S switch IF "%UseSeparator%"=="1" ECHO.%Separator% :: Display aligned values ECHO.%DisplayName%%DisplayVersion% GOTO:EOF :Display SET DisplayName=%~1 SET DisplayVersion=%~2 IF /I NOT "%Format%"=="List" ( CALL :%Format% GOTO:EOF ) FOR /F "tokens=1* delims==" %%E IN ('SET _RegKey.!DisplayName!') DO SET RegKey="%%~F" CALL :%Format% !RegKey! GOTO:EOF :List :: Display values as list ECHO Registry Key = %~1 ECHO Display Name = %DisplayName% ECHO Display Version = %DisplayVersion% ECHO. GOTO:EOF :TabDelimited :: Display tab delimited values ECHO.%DisplayName% %DisplayVersion% GOTO:EOF :Syntax ECHO. ECHO ListProgs.bat, Version 1.11 ECHO List "all" installed program names and versions found in the registry ECHO. ECHO Usage: LISTPROGS [ "pattern" ] [ /A ^| /S ^| /T ] ECHO. ECHO Where: "pattern" limits output to DisplayName values matching the FINDSTR ECHO type regular expression "pattern" (case insensitive) ECHO /A shows results in Aligned table (default: List) ECHO /S aligned table with Separator lines (default: List) ECHO /T shows results Tab delimited (default: List) ECHO. ECHO Notes: Searches HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall and ECHO HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall ECHO for subkeys that have both DisplayName and DisplayVersion set. ECHO Registry keys are displayed in the default List output, but not in ECHO Aligned output nor in Tab delimited output. ECHO With Aligned output (/A) a window width of 110 columns or wider ECHO is recommended - may be set with the command: MODE CON COLS=110 ECHO. ECHO Written by Rob van der Woude ECHO http://www.robvanderwoude.com EXIT /B 1