11/30/2009 2757 views
Has anyone ever come across a VB method or WMI query that can tell me what features are installed for a particular MSI that is installed on a computer?

Basically, I want to write a script that takes an action depending on what features are installed for this particular MSI.

I looked Win32_SoftwareFeatureCheck and some other Windows Installer WMI classes, but couldn't find anything useful. Anybody had to do something like this?
0 Comments   [ + ] Show comments


Community Chosen Answer

Check out the WiLstPrd.vbs from the SDK.

The code-snip you're after will be:

If InStr(1, optionFlag, "f", vbTextCompare) > 0 Then
Dim feature, features, parent, state, featureInfo
Set features = installer.Features(productCode)
message = "---Features in product " & productCode & "---"
For Each feature In features
parent = installer.FeatureParent(productCode, feature) : CheckError
If Len(parent) Then parent = " {" & parent & "}"
state = installer.FeatureState(productCode, feature)
Select Case(state)
Case msiInstallStateBadConfig: state = "Corrupt"
Case msiInstallStateIncomplete: state = "InProgress"
Case msiInstallStateSourceAbsent: state = "SourceAbsent"
Case msiInstallStateBroken: state = "Broken"
Case msiInstallStateAdvertised: state = "Advertised"
Case msiInstallStateAbsent: state = "Uninstalled"
Case msiInstallStateLocal: state = "Local"
Case msiInstallStateSource: state = "Source"
Case msiInstallStateDefault: state = "Default"
Case Else: state = "Unknown"
End Select
message = message & vbNewLine & feature & parent & " = " & state
Set features = Nothing
Wscript.Echo message
End If
Answered 11/30/2009 by: AngelD
Red Belt

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

All Answers

Very cool. Thanks much for the quick reply, had the answer on my PC and didn't even know it. [:D]
Answered 11/30/2009 by: elgwhoppo
Senior Purple Belt

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login