“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

  • Anonymous
    January 13, 2012
    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!

  • Anonymous
    January 14, 2012
    Pablo Montilla, Cool! Thanks for sharing. :)

  • Anonymous
    March 06, 2012
    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.

  • Anonymous
    March 07, 2012
    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.

  • Anonymous
    March 07, 2012
    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

  • Anonymous
    March 08, 2012
    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!

  • Anonymous
    March 09, 2012
    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.

  • Anonymous
    March 09, 2012
    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!

  • Anonymous
    March 10, 2012
    Your fix works, you are the man!