views:

428

answers:

4

For some reason, we are delivering a product with our own install GUI, that means, we will run the msi installation silently background.

By using the MSI API "MsiInstallProduct", I can install the product silently, but I have no idea how can I get the progress data of this installation and how can I cancel it.

Anyone has some ideas?

+1  A: 

I believe you can get the progress via the MSI API, but if I were you I would just show the progress bar from the MSI itself after invoking the install via msiexec.exe.

MSI supports several different installation levels (full, completely silent, basic GUI, reduced GUI etc...). In your case it sounds like you want a basic UI. This yields a progress bar where you can hide the cancel button, and optionally show a completion modal dialog:

Install silently with progress bar, no cancel button and no modal dialog at end:

msiexec.exe /I "Test.msi" /QB-!

To avoid having to construct these silly msiexec command lines manually, use the msi command line builder tool from Wise: http://www2.wise.com/filelib/WICLB.exe

Glytzhkof
I will get you a vote but not for my answer.We are not using the msi GUI because it's not fit our product's style, so we are provide a cooler progress bar for it, all I need is the progress data to set our bar.The msi's basic GUI is not acceptable.And I still cannot cancel it from pure API right?
redjackwong
Here is a sample of how to work with MSI billboards and progress bar: http://sourceforge.net/projects/msiprogramming/ . If this isn't what you need, perhaps look through the resources at: http://www.installsite.org
Glytzhkof
Remember to click the "view all files" button (otherwise you get only a demo).
Glytzhkof
+1  A: 

You need to specify an external UI handler using MsiSetExternalUI or MsiSetExternalUIRecord before MsiInstallProduct (the latter is nicer, but has a higher MSI version requirement). The function you specify will be called for each message Windows Installer wants you to process. This will give you the data, and a chance to respond tell it to cancel. If you require MSI 4.5 or later, you can use an embedded external UI handler DLL, which does not require a bootstrap.

Michael Urman
Thank you, MsiSetExternalUI does work for this case~
redjackwong
+1  A: 

Here is a sample project that appears to do what you are referring to: http://www.codeproject.com/KB/cs/msiinterop.aspx

Glytzhkof
A: 

May be you can try using Nvn Installer. It interacts with Windows Installer and gives progress messages, progress bar value etc during installation. It also provides lot of other features like getting list of features, its cost in KBytes, whether that feature is currently installer and lot more. I hope this helps !

kumar