1

I know that MsiEnumFeatures is the goto API for detecting what features are installed by a given MSI, but I'm finding that it doesn't return any features where the InstallLevel was set to '0' at install time.

Scenario: I have an MSI with 20 features: 10 get installed, 5 are not selected for installation, and 5 are also not installed AND not supported (InstallLevel = 0).

When I call MsiEnumProducts and loop through the features I'll end up having only the first 15 returned to me.

Why does it not return the last 5? Is there any API to give me that or do I simply have to run a SQL query against the File table to get a list of all the features?

jbudreau
  • 1,287
  • 1
  • 10
  • 22
  • I haven't looked at this in a long time. [What do you get if you run the script here](https://stackoverflow.com/a/50421158/129130)? ([the same script on github](https://github.com/glytzhkof/all/blob/master/MSI%20Features.vbs)). – Stein Åsmul Jun 08 '21 at 00:34

2 Answers2

2

Because...

The MsiEnumFeatures function enumerates the published features for a given product.

...and level 0 features aren't published. If you want to know potential features you need to query the package.

Bob Arnson
  • 21,377
  • 2
  • 40
  • 47
1

InstallExplorer: Bob Arnson from the WiX team has answered already, but maybe I can add an example that I found just now. I was looking for something else, but couldn't find that, but this might do: InstallExplorer. It is a small C++ GUI application which lists installed products. Maybe have a look at it and see if it does what you need - at the very least it is a sample for MSI API code.

DTF - Inventory Sample: Hold on, thought of something else. The DTF component of WiX has some samples. There is something there. I think its "Inventory" sample actually reads features from the MSI itself. I am not positive, it has been a long time since I looked at it. If it does not compile, maybe create a brand new C# project and shove the source files in there and try again.

DTF is essentially a managed code wrapper for the Windows MSI API - and then some - it is a great little toolkit. Find the documentation on disk in the "doc" folder of the main WiX installation directory. Files: "DTF.chm" and "DTFAPI.chm".

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • 1
    DTF would make querying the package easy but first you have to find it. – Bob Arnson Jun 08 '21 at 03:32
  • Yes, that's right. I added two links at the bottom of the answer. The files are in a subfolder of the main WiX 3 installation directory (on the system drive). – Stein Åsmul Jun 08 '21 at 13:35
  • I meant finding the package. – Bob Arnson Jun 08 '21 at 16:55
  • You can just get the `INSTALLPROPERTY_LOCALPACKAGE` path? The locally cached package in `C:\Windows\Installer\[randomname].msi`. In VBScript: `packagepath = product.InstallProperty("LocalPackage")` and in C++ you get property: `INSTALLPROPERTY_LOCALPACKAGE` (which can be quite annoying with all the clunk - let us know if you need a sample - need to dig it up - maybe check the InstallExplorer link above). – Stein Åsmul Jun 08 '21 at 17:25
  • I'm aware. But "just"? – Bob Arnson Jun 08 '21 at 17:57
  • Seeing as you almost wrote the book on this, I doubt anyone else would be as aware :-). I should have added this to the answer itself. – Stein Åsmul Jun 08 '21 at 19:11