Programming Windows

VBScript: List all installed applications

Just a simple inventory script. This script does NOT query the WMI Installed_Product table, which an be quite time and CPU consuming. Instead, my script queries the Uninstall-Registry key to generate the list of installed apps which makes it lot faster:

' #####################################################################
' ##
' ## (C) 2010 Michael Miklis (michaelmiklis.de)
' ##
' ## 
' ## Filename:      GetInstalledApplications.vbs
' ##
' ## Version:	    1.0
' ##
' ## Release:	    Final 
' ##
' ## Requirements:  -none-
' ## 
' ## Description:   List installed applications based on uninstall key
' ##
' ## This script is provided 'AS-IS'.  The author does not provide 
' ## any guarantee or warranty, stated or implied.  Use at your own 
' ## risk. You are free to reproduce, copy & modify the code, but 
' ## please give the author credit. 
' ##
' ####################################################################
Option Explicit


wscript.echo GetInstalledApplications


'______________________FUNCTIONS & SUB ROUTINES_______________________

Function GetInstalledApplications
	'// <summary> 
	'// List installed applications
	'// </summary>
	'// <param name="strComputername">Computername</param>
 
	Const HKLM = &H80000002		'HKEY_LOCAL_MACHINE

	Dim objREG			'Registry Object
	Dim strBaseKey			'Uninstall Key
	Dim intRet			'Return Code
	Dim arSubKeys			'Reg-Key Array
	Dim strKey			'Reg-Key Element
	Dim strValue			'Reg-Value

	Set objREG = GetObject("winmgmts:{impersonationLevel=impersonate}!./root/default:StdRegProv")
	strBaseKey = "SOFTWAREMicrosoftWindowsCurrentVersionUninstall"

	intRet = objREG.EnumKey(HKLM, strBaseKey, arSubKeys)

	For Each strKey In arSubKeys
		intRet = objREG.GetStringValue(HKLM, strBaseKey & strKey, "DisplayName", strValue)

		If intRet <> 0 Then
			objREG.GetStringValue HKLM, strBaseKey & strKey, "QuietDisplayName", strValue
		End If

		If strValue <> "" Then
			GetInstalledApplications = GetInstalledApplications & strValue & vbCrLf
		End If
	Next
End Function
You may also like
LotusScript: Move all items without a view into Inbox Folder
VBScript: List all files in a directory recursively
Creating PowerShell scripts with a GUI

Leave Your Comment

Your Comment*

Your Name*
Your Webpage