I am trying to . . .
[1] Output a .txt file of the list of the installed programs [like those in Programs and Features].
[2] Delete [exclude] any duplicates in the file.
[3] Sort the file.
[4] Output the file to the desktop.
I have managed to do all of the above, BUT . . .
[1] It outputs some of the data in the cmd prompt [which I DON'T want].
[2] In the cmd prompt it says String count error: (0 does not equal 1) but it doesn't seem to have an impact on the final file which works!
Code: Select all
@echo off
regedit /E C:\RegX1.txt "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall"
regedit /E C:\RegX2.txt "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall"
regedit /E C:\RegX3.txt "HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
Find "DisplayName" C:\RegX1.txt > C:\SoftProgs.txt
Find "DisplayName" C:\RegX2.txt >> C:\SoftProgs.txt
Find "DisplayName" C:\RegX3.txt >> C:\SoftProgs.txt
For /f "tokens=2 delims==" %%a in (C:\SoftProgs.txt) Do echo %%~a >> C:\InstalledProgs.txt
Type nul>C:InstalledProgs_Final.txt
For /f "tokens=* delims=" %%a In (C:\InstalledProgs.txt) Do (
FindStr /ixc:"%%a" C:InstalledProgs_Final.txt || >> C:InstalledProgs_Final.txt echo.%%a
)
rem ) > NUL <<<=========================
Sort InstalledProgs_Final.txt > %userprofile%\Desktop\InstalledProgs_Final1.txt
Del C:\RegX1.txt
Del C:\RegX2.txt
Del C:\RegX3.txt
Del C:\SoftProgs.txt
Del C:\InstalledProgs.txt
Del InstalledProgs_Final.txt
Pause
[2] I would like however, to stop or suppress the String count error: (0 does not equal 1) message in the cmd prompt, is there an easy way to achieve this please?
[3] The code is a bit of a mess really [a lot of C:\'s] , is there a neater way to do this please?
EDIT:
There seems to be a blank/empty line at the bottom of the .txt file. Would this cause the error String count error: (0 does not equal 1)?
Any help will be greatly appreciated.