Juri Strumpflohner
Juri Strumpflohner Juri is a full stack developer and tech lead with a special passion for the web and frontend development. He creates online videos for Egghead.io, writes articles on his blog and for tech magazines, speaks at conferences and holds training workshops. Juri is also a recognized Google Developer Expert in Web Technologies

Retrieving list of installed applications

3 min read

From now and then it happens that you have to reset your workstation, meaning to reformat your hard disk and install everything fresh. In this way you get rid of all the garbage on your PC. In such a case it may be useful afterwards to have a list of all of the previously installed applications in order to have your loved, every-day used programs :) installed and configured. Opening the "Add or remove programs" entry of the control panel for copying (by hand) all of the entries is for sure not the best approach for that. Usually as software developer you are too lazy to do such things manually and you try to automate things as much as possible (also if sometimes at the end it costs you more time ;) ).
Actually there is an automated solution for this problem here (otherwise of course I wouldn't probably write this post here). I have two different versions. The first, which is the simpler one, queries the Windows registry, while the second queries directly the WMI service. You can simply start the script and wait till the "Done" message box appears. The softwareSimple.vbs and the softwareExtended.vbs create a software_simple.csv and a software_ext.tsv correspondingly. The best way to view them is to open them with MS Excel or another spreadsheet application.

SoftwareSimple.vbs
strHost = "."
Const HKLM = &H80000002
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("software_simple.csv", True)
objTextFile.WriteLine "Program Name" & ";" & "Installation date"
Set objReg = GetObject("winmgmts://" & strHost & "/root/default:StdRegProv")
Const strBaseKey = "Software\Microsoft\Windows\CurrentVersion\Uninstall\"
objReg.EnumKey HKLM, strBaseKey, arrSubKeys
For Each strSubKey In arrSubKeys
intRet = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, "DisplayName", strValue)
If intRet <> 0 Then
intRet = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, "QuietDisplayName", strValue)
End If
intRet1 = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, "InstallDate", strValue2)
If (strValue <> "") and (intRet = 0) Then
objTextFile.WriteLine strValue & ";" & strValue2
End If
Next
WScript.Echo "Done"
objTextFile.Close


SoftwareExtended.vbs
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("software_ext.tsv", 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.Version
Next
WScript.Echo "Done"
objTextFile.Close


You can also download them from here:
softwarevbscripts.zip
Questions? Thoughts? Hit me up on Twitter
comments powered by Disqus