List installed programs (VBScript)
This bit of VBScript will allow you to return a list of applications installed (as seen by Add/Remove Programs). The function returns a simple Array() containing the list of applications installed.
Combined with an ADSI script that returns a list of computers, you can use this function to iterate through all machines on your network to gather a list of installed applications on each machine.
Function getApps(strComputer)
HKLM = &H80000002 'HKEY_LOCAL_MACHINE
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}//" & _
strComputer & "/root/default:StdRegProv")
If Err.Number > 0 Then
getApps = False
Err.Clear
Exit Function
End If
objReg.EnumKey HKLM, strKey, arrSubkeys
arrInstalledApps = Array()
For Each strSubkey In arrSubkeys
‘====== Display Name ========
intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, “DisplayName”, strValue1)
If intRet1 <> 0 Then
objReg.GetStringValue HKLM, strKey & strSubkey, “QuietDisplayName”, strValue1
End If
If InStr(strValue1, “Hotfix”) Or InStr(strValue1, “Security Update”) Or InStr(strValue1, “Update for Windows”) Then
‘Nothing
Elseif strValue1 <> “” Then
ReDim Preserve arrInstalledApps(UBound(arrInstalledApps) + 1)
arrInstalledApps(UBound(arrInstalledApps)) = strValue1
End If
Next
getApps = arrInstalledApps
End Function
Now I’m sure you want to know how to access the function too so here’s the code you need to do just that.
On Error Resume Next
strComputer = “.”
arrIA = getApps(strComputer)
If IsArray(arrIA) Then
WScript.Echo “There are ” & UBound(arrIA)+1 & ” applications installed on ” & UCase(strComputer) & VbCrLf
i = 1
For Each strApp In arrIA
WScript.Echo i & “: ” & strApp
i = i + 1
Next
Else
WScript.Echo “Unable to connect.”
End If