Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 



Sign in to follow this  
twig123

Batch - Collecting Installed software

Recommended Posts

crobertson,

Are you looking to create a file containing the customer information contained in the variable (%destination%) and the list of installed applications?

If so, perhaps this will work for you:

@Echo off
set destination=%date% - My Customer
type nul>.\apps.txt
type nul>.\sorted.txt
for /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
echo %destination%>.\destination.txt
>nul copy .\destination.txt+.\sorted.txt .\backup.txt

If this is not correct, please rephrase your question to explain exactly what you are looking for.

Share this post


Link to post
Share on other sites

Here is a script that enumerates the unistall keys in the registry, it produces a text file.

Save As ReadRegisteryInstallApps.vbs


Const HKLM = &H80000002
Dim StrComputer :StrComputer = "."

Dim Act :Set Act = CreateObject("WScript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Key :Key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Dim Reg :Set Reg = GetObject("winmgmts://" & StrComputer & _
"/root/default:StdRegProv")
Dim Arr :Arr = Array( _
"DisplayName", "QuietDisplayName", "InstallDate", _
"VersionMajor", "VersionMinor","EstimatedSize")

Dim Ts, Txt

Txt = Act.SpecialFolders("Desktop") & "\InstallApplications.txt"
Set Ts = Fso.CreateTextFile(Txt)
Reg.EnumKey HKLM, Key, arrSubkeys

Ts.WriteLine vbtab & "List Of Installed Applications"

For Each strSubkey In arrSubkeys
int1 = Reg.GetStringValue(HKLM, Key & strSubkey, Arr(0), str1)
If int1 <> 0 Then Reg.GetStringValue HKLM, Key & strSubkey, Arr(1), str1
If Not IsNull(str1) Then
Ts.WriteLine _
"----------------------------------------------------------------" & _
vbCrLf & "Item Name " & vbTab & str1
End If
Reg.GetStringValue HKLM, Key & strSubkey, Arr(2), str2
If Not IsNull(str2) Then
Ts.WriteLine "Install On " & vbTab & str2
End If
Reg.GetDWORDValue HKLM, Key & strSubkey, Arr(3), str3
Reg.GetDWORDValue HKLM, Key & strSubkey, Arr(4), str4
If Not IsNull(str3) Then
Ts.WriteLine "Version " & vbTab & str3 & "." & str4
End If
Reg.GetDWORDValue HKLM, Key & strSubkey, Arr(5), str5
If Not IsNull(str5) Then
Ts.WriteLine "File Size " & vbTab & Round(str5/1024, 3) & " MB"
End If
Next
Ts.Close
'-> Open Text Report
Act.Run(Txt),1,True
'-> Ask To Keep Or delete File
If MsgBox("Would you like to keep this file?" & vbCrLf & _
Txt, 4132,"Yes To Keep, No To Delete File?") = 7 Then
Fso.DeleteFile Txt,True
End If

Rename ReadRegisteryInstallApps.vbs.txt to ReadRegisteryInstallApps.vbs to make active.

ReadRegisteryInstallApps.vbs.txt

Share this post


Link to post
Share on other sites

Here's an autoit version with a listview. In the listview there is additional functionality to right click and uninstall a selection (additional snippets are credited in the source). This version also dumps a log.txt with all items in the uninstall key, as some of the other solutions do.

InstalledSoftware.zip

Edited by iamtheky

Share this post


Link to post
Share on other sites

Since we've moved on to "not batch" solutions, here's a couple PowerShell quickies:

gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*|select DisplayName,DisplayVersion,Publisher,UninstallString|sort DisplayName

This outputs all installed software (and version, publisher, uninstall string) at the console. If you want to save it as a HTML file, try:

gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*|select DisplayName,DisplayVersion,Publisher,UninstallString|sort DisplayName|ConvertTo-Html|Out-File C:\some\path\somename.htm

That will generate the same list, format it as a HTML table, and save it to C:\some\path\somename.htm If you want the same list, but saved as a CSV file to open with Excel, try:

gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*|select DisplayName,DisplayVersion,Publisher,UninstallString|sort DisplayName|ConvertTo-CSV -NoTypeInformation|Out-File C:\some\path\somename.csv

Note that sometimes Excel needs a bit of help to open CSV files properly. It might think it's fixed width, so if it does then tell it it's comma separated and it'll open fine, with each property in a separate column. You could also have manipulated Excel directly using its COM interface (Excel.Application) to create a real Excel document, assuming Excel is installed.

Finally, if you just want to see it graphically on your screen (using a gridview), try:

gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*|select DisplayName,DisplayVersion,Publisher,UninstallString|sort DisplayName|ogv

Quick, easy and flexible.

Share this post


Link to post
Share on other sites

Thats badass fiend

Thanks! It's really not that impressive though. It's mainly a matter of having taken time to learn PowerShell (and VBScript a decade before, and batch another decade before that). It's different and it takes time but it really pays off to learn new tools. So much people just don't invest the time, even to learn their current tools decently. I would bet that half the people on this board who still do batch today never even pressed F7 at the console ;) Yep, that's been there for over 20 years.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×