First Published 6 Oct 2022
This article provides code to get a list of all installed apps and program updates as displayed in the Apps section of Windows Settings
The application data is saved to a table tblInstalledApps with the following fields:
ProgramID AutoNumber (primary key)
ProgramName Short text (255 char)
InstallLocation Short text (255 char)
UninstallString Short text (255 char)
The data can be displayed in a form:
The application data is automatically updated when the form is loaded. This normally takes no more than a second to complete.
The form can be filtered to show the details of a selected app:
The code works in both 32-bit and 64-bit Access. No additional references are required
The code should be placed in a standard module
CODE:
Option Compare Database
Option Explicit
Public Function GetAddRemove(sComp)
'Based on an original function by Torgeir Bakken
'Modified by Colin Riddington (Mendip Data Systems) 12/07/2021
Dim oReg As Object, sBaseKey As String, iRC As String, aSubKeys As Variant
Dim sKey, sValue, instloc, UninstallString 'variants
Dim ProgName As String, strSQL As String
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
sComp & "/root/default:StdRegProv")
sBaseKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
'empty existing table
CurrentDb.Execute "DELETE * FROM tblInstalledApps", dbFailOnError
'get registry values
iRC = oReg.EnumKey(HKLM, sBaseKey, aSubKeys)
'populate table
For Each sKey In aSubKeys
iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, "DisplayName", sValue)
If sValue <> "" Then
ProgName = sValue
iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, "InstallLocation", sValue)
instloc = sValue
iRC = oReg.GetStringValue(HKLM, sBaseKey & sKey, "UninstallString", sValue)
UninstallString = sValue
strSQL = "INSERT INTO tblInstalledApps (ProgramName, InstallLocation, UninstallString)
VALUES ('" & ProgName & "','" & instloc & "', '" & UninstallString & "');"
CurrentDb.Execute strSQL, dbFailOnError
End If
Next
'show message (optional)
' Dim N As Integer
' N = DCount("*", "tblInstalledApps")
' MsgBox N & " programs have been added to tblInstalledApps", vbInformation, "All done!"
End Function
'--------------------------------------
Sub GetInstalledApps()
GetAddRemove (Environ("ComputerName"))
End Sub
Run the GetInstalledApps procedure to save the list of installed apps to the table
Download
The attached app includes all required code together with the table and form
Click to download:
Installed Apps (ACCDB - 0.5 MB zipped)
Feedback
Please use the E-Mail button in the contact form below to let me know whether you found this article useful or if you have any questions.
Please also consider making a donation towards the costs of maintaining this website. Thank you
Colin Riddington Mendip Data Systems Last Updated 6 Oct 2022
|
Return to Code Samples Page
|
Return to Top
|