twig123 Posted October 20, 2008 Share Posted October 20, 2008 Hey all,I'm trying to make my batch file gather the installed Applications, and I need some help trying to filter and sort the data. Here is what I have so far:Reg Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /S>c:\temp\installedsoftware.txtFOR /f "tokens=3 delims= " %%a in ('find "DisplayName REG_SZ" c:\temp\installedsoftware.txt') do Echo %%a>>C:\temp\newsoft.txtI need to filter out all of the Windows Updates and Security Patches and junk... and then sort the list in Alph. Order.I botched together some code to filter, but it is very inefficient and maybe someone can improve on it for me: @Echo OffEcho.>C:\temp\newsoft.txtEcho.>C:\temp\newsoft2.txtEcho.>C:\temp\newsoft3.txtEcho.>C:\temp\newsoft4.txtEcho.>C:\temp\newsoft5.txtEcho.>C:\temp\newsoft6.txtReg Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /S>c:\temp\installedsoftware.txtFOR /f "tokens=3 delims= " %%a in ('find "DisplayName REG_SZ" c:\temp\installedsoftware.txt') do Echo %%a>>C:\temp\newsoft.txtFOR /f "tokens=* skip=3 delims=" %%b in ('find "Microsoft" /v c:\temp\newsoft.txt') do Echo %%b>>C:\temp\newsoft2.txtFOR /f "tokens=* skip=3 delims=" %%b in ('find "Hotfix" /v c:\temp\newsoft2.txt') do Echo %%b>>C:\temp\newsoft3.txtFOR /f "tokens=* skip=3 delims=" %%b in ('find "Security Update for" /v c:\temp\newsoft3.txt') do Echo %%b>>C:\temp\newsoft4.txtFOR /f "tokens=* skip=3 delims=" %%b in ('find "- Software Updates" /v c:\temp\newsoft4.txt') do Echo %%b>>C:\temp\newsoft5.txtFOR /f "tokens=* skip=3 delims=" %%b in ('find "Update for Windows" /v c:\temp\newsoft5.txt') do Echo %%b>>C:\temp\newsoft6.txtDEL /Q C:\temp\newsoft.txtDEL /Q C:\temp\newsoft2.txtDEL /Q C:\temp\newsoft3.txtDEL /Q C:\temp\newsoft4.txtDEL /Q C:\temp\newsoft5.txtpauseThanks in advance Link to comment Share on other sites More sharing options...
Scr1ptW1zard Posted October 20, 2008 Share Posted October 20, 2008 Here's my quick thought on performing this task via batch:@Echo Offfor /f "tokens=2,*" %%a in ('Reg Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /S^|find " DisplayName"') do ( echo %%b|findstr /B /V /C:"Hotfix"|findstr /B /V /C:"Security Update"|findstr /B /V /C:"Update">>.\apps.txt)sort .\apps.txt /o .\sorted.txtYou should be careful of what you filter out. I did not filter out "Microsoft" as you did in your post, since that would remove the Microsoft Office products. Link to comment Share on other sites More sharing options...
twig123 Posted October 21, 2008 Author Share Posted October 21, 2008 Thanks!I just tested your code and it works great... except I get an error:'Hauspie' is not recognized as an internal or external command, operable program or batch file....The code finishes and it gathers all the data and sorts it, so I am at a loss for where this is coming from. On top of that, I don't even have anything installed called 'Hauspie' ... Link to comment Share on other sites More sharing options...
twig123 Posted October 21, 2008 Author Share Posted October 21, 2008 Ahh... searched that key and found that the name has a '&' in the name.Now to figure out how to modify the code to accommodate the symbol... Link to comment Share on other sites More sharing options...
cluberti Posted October 21, 2008 Share Posted October 21, 2008 Vbscript for enumerating hotfixes installed, output to a tab-delimited file that can be opened in Excel:Set objFSO = CreateObject("Scripting.FileSystemObject")Set objTextFile = objFSO.CreateTextFile("c:\TEMP\installedhotfixes.txt", True)strComputer = "."Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colQuickFixes = objWMIService.ExecQuery _ ("SELECT * FROM Win32_QuickFixEngineering")objTextFile.WriteLine "Caption" & vbtab & _"Description" & vbtab & "FixComments" & vbtab & _"HotFixID" & vbtab & "Install Date" & vbtab & _"InstalledBy" & vbtab & "InstalledOn" & vbtab & _"Name" & vbtab & "ServicePackInEffect"For Each objQuickFix in colQuickFixes objTextFile.WriteLine objQuickFix.Caption & vbtab & _ objQuickFix.Description & vbtab & _ objQuickFix.FixComments & vbtab & _ objQuickFix.HotFixID & vbtab & _ objQuickFix.InstallDate & vbtab & _ objQuickFix.InstalledBy & vbtab & _ objQuickFix.InstalledOn & vbtab & _ objQuickFix.Name & vbtab & _ objQuickFix.ServicePackInEffectNextobjTextFile.CloseVBScript for enumerating software installed, output to a tab-deliminted file that can be opened in Excel:Set objFSO = CreateObject("Scripting.FileSystemObject")Set objTextFile = objFSO.CreateTextFile("c:\TEMP\installedsoftware.txt", True)strComputer = "."Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colSoftware = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Product")objTextFile.WriteLine "Caption" & vbtab & _"Description" & vbtab & "Identifying Number" & vbtab & _"Install Date" & vbtab & "Install Location" & vbtab & _"Install State" & vbtab & "Name" & vbtab & _"Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _ & "Version"For Each objSoftware in colSoftware objTextFile.WriteLine objSoftware.Caption & vbtab & _ objSoftware.Description & vbtab & _ objSoftware.IdentifyingNumber & vbtab & _ objSoftware.InstallDate & vbtab & _ objSoftware.InstallLocation & vbtab & _ objSoftware.InstallState & vbtab & _ objSoftware.Name & vbtab & _ objSoftware.PackageCache & vbtab & _ objSoftware.SKUNumber & vbtab & _ objSoftware.Vendor & vbtab & _ objSoftware.VersionNextobjTextFile.CloseI separated them, because the hotfix one can take some time to run (whereas the software one runs very quickly). You could, however, easily merge them into one larger vbscript and run them as functions, for instance. Link to comment Share on other sites More sharing options...
CoffeeFiend Posted October 22, 2008 Share Posted October 22, 2008 I think this is done a LOT better in other ways too (not batch) i.e. vbscript/jscript or even powershell (exporting a list of this to a HTML page would be a one-liner). But the Win32_Product class is very slow as it starts the windows installer engine... Reading directly from the registry is probably a lot quicker. Link to comment Share on other sites More sharing options...
cluberti Posted October 22, 2008 Share Posted October 22, 2008 I think this is done a LOT better in other ways too (not batch) i.e. vbscript/jscript or even powershell (exporting a list of this to a HTML page would be a one-liner). But the Win32_Product class is very slow as it starts the windows installer engine... Reading directly from the registry is probably a lot quicker.Well, there are many other ways that are more powerful, as in writing an app in C++ to do this would be most preferable - but Win32_Product and Win32_QuickFixEngineering work fine. I agree though, for a low-hanging fruit, powershell is probably the best option - I didn't even think of it (I was in a hurry earlier to eat dinner ). Link to comment Share on other sites More sharing options...
twig123 Posted October 24, 2008 Author Share Posted October 24, 2008 Set objFSO = CreateObject("Scripting.FileSystemObject")Set objTextFile = objFSO.CreateTextFile("c:\TEMP\installedsoftware.txt", True)strComputer = "."Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")Set colSoftware = objWMIService.ExecQuery _ ("SELECT * FROM Win32_Product")objTextFile.WriteLine "Caption" & vbtab & _"Description" & vbtab & "Identifying Number" & vbtab & _"Install Date" & vbtab & "Install Location" & vbtab & _"Install State" & vbtab & "Name" & vbtab & _"Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _ & "Version"For Each objSoftware in colSoftware objTextFile.WriteLine objSoftware.Caption & vbtab & _ objSoftware.Description & vbtab & _ objSoftware.IdentifyingNumber & vbtab & _ objSoftware.InstallDate & vbtab & _ objSoftware.InstallLocation & vbtab & _ objSoftware.InstallState & vbtab & _ objSoftware.Name & vbtab & _ objSoftware.PackageCache & vbtab & _ objSoftware.SKUNumber & vbtab & _ objSoftware.Vendor & vbtab & _ objSoftware.VersionNextobjTextFile.CloseThis does not pull all of my installed software...Ex: I have 7-zip installed and it is not in the list when I run this However, I verified that it IS in the registry in the Uninstall key.Any ideas? Link to comment Share on other sites More sharing options...
Yzöwl Posted October 25, 2008 Share Posted October 25, 2008 Product only provides you with Software which was installed using Windows Installer, the only way I can suggest is to get a listing form the registry uninstall key. Link to comment Share on other sites More sharing options...
Scr1ptW1zard Posted October 26, 2008 Share Posted October 26, 2008 If you still need a batch script...Here is the modified version of my previous script that will take into account the "&" sign:@Echo Offtype nul>.\apps.txttype nul>.\sorted.txtfor /f "tokens=2,*" %%a in ('Reg Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /S^|find " DisplayName"') do (echo "%%b"|findstr /B /V /C:"Hotfix"|findstr /B /V /C:"Security Update"|findstr /B /V /C:"Update">>.\apps.txt)sort .\apps.txt /o .\sorted.txtBut now the output will have quotation marks around every name. With some work, they can be removed also. Link to comment Share on other sites More sharing options...
Yzöwl Posted October 26, 2008 Share Posted October 26, 2008 Here's a quickly put together 'compiled' batch file which may help give you a console listing. I've not tested it on all OSes etc. but it was intended to work with a good few.PSI've not bothered checking to see how it copes with badly named products, if you've got software using `poison` characters then you may be out of luck with this attempt!OnMyPC.zip Link to comment Share on other sites More sharing options...
twig123 Posted November 3, 2008 Author Share Posted November 3, 2008 @Yzöwl - This seems to pull the listings of my apps (Including the pesky one 7zip for some reason was not found in the previous scripts). I would need it output to a file and sorted, however, I could manage that if you felt like being generous and sharing the source... Link to comment Share on other sites More sharing options...
Yzöwl Posted November 24, 2008 Share Posted November 24, 2008 @twig123 I'm sorry for not having responded sooner to your request.Here is an altered version which hopefully creates a SoftList.log file along side the executable.NoteThis file may take some time to complete on a machine with plenty of installed software, so please be patient!OnMyPC.zip Link to comment Share on other sites More sharing options...
bhuvan Posted March 15, 2012 Share Posted March 15, 2012 Can u please also help me get other details besides software name like install location/path, install datei will then filter apps which i dont want. bat script is appreciated Link to comment Share on other sites More sharing options...
crobertson Posted May 22, 2012 Share Posted May 22, 2012 Scr1ptW1zardI'm using your little batch script------------------------------type nul>.\apps.txttype nul>.\sorted.txtfor /f "tokens=2,*" %%a in ('Reg Query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall /S^|find " DisplayName"') do (echo "%%b"|findstr /B /V /C:"Hotfix"|findstr /B /V /C:"Security Update"|findstr /B /V /C:"Update">>.\apps.txt)sort .\apps.txt /o .\sorted.txt-------------------------------And I have a path variable I'm putting everything in that I'm backing up (includes date and customer's name)I'm trying to modify this clippet to include the variable %destination% .. I've tried several times but can't seem to make it work.Any ideas?This utility collects drivers, files from current users, software keys for windows re-install. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now