“Make things as simple as possible, but not simpler.” [ManagedMsiExec sample app shows how to use the Windows Installer API from managed code]


This blog has moved to a new location and comments have been disabled.

All old posts, new posts, and comments can be found on The blog of dlaa.me.

See you there!

Comments (9)
  1. Pablo Montilla says:

    I've always wrapped the msiexec executable proper, instead of trying to use the API directly (always thought it was much too difficult). Seeing your code I see it wasn't a correct assumption, nice work!

  2. Delay says:

    Pablo Montilla,

    Cool! Thanks for sharing. 🙂

  3. Jay says:

    This is very cool! However, there is something wrong with major upgrade scenario. Old MSI is does not get uninstalled, so in Add/Remove programs you can see all versions of your application. Using msiexec on the next version removes all previous versions installed by the tool.

    I'd appreciate any ideas.

  4. Delay says:

    Jay,

    All the "real" installer work is handled by Windows Installer, so I'm guessing you'd see the same behavior invoking that MSI directly or via MsiExec. If so, then I think the problem lies in how the MSI itself is authored – and upgrades can be a tricky thing to get right. But if you're saying that MsiExec and ManagedMsiExec are exhibiting different behavior, that would be surprising and something I could try to look into if you had an example of an MSI that behaved inconsistently.

  5. Jay says:

    David, this was my expectation as well. Please find example MSIs (binaries and WiX 3.5 source) along with steps to reproduce the problem here: 2mem.com/VersionedMsi.zip

  6. Delay says:

    Jay,

    Thanks for the excellent demonstration of the problem!! Indeed, I see the same behavior you describe. I've only had a bit of time to look into this, but my findings are consistent with the following StackOverflow thread (except that workaround doesn't seem to work here): stackoverflow.com/…/duplicate-entries-in-add-removeprograms-control-panel-when-using-msisetexternalu

    In particular, I independently had the same idea about CLIENTUILEVEL because the property output in verbose mode shows it being quite wrong. My initial attempts to correct this were unsuccessful, but I'll look at this again on the bus tomorrow and maybe I'll have better luck. 🙂

    Thanks for your patience!

  7. Delay says:

    Jay,

    I figured out a way just as the bus pulled in! 🙂 I'll update the ManagedMsiExec code+binary as well as the StackOverflow thread sometime this evening.

  8. Delay says:

    Jay,

    I've just updated the ManagedMsiExec code and binary linked to by my post above to work around what appears to be a Windows Installer bug. The new implementation should work correctly in your scenario – I used your example MSIs to test it! 🙂 Please give it a try and let me know if you agree. Assuming you do, I'll update the StackOverflow thread.

    Thanks!

  9. Jay says:

    Your fix works, you are the man!

Comments are closed.