问题
I'm writing a small app to install some product and uninstall some other in silent mode.
Every product has its MSI file and nothing else and my app manifest states that it should be run with admin privileges.
It's pretty easy to run msiexec
with proper arguments to accomplish my task (just a bunch of code) and everything is working fine.
Anyway some package takes a lot of time to finish and on some old pc user is asking if something is still going on in background or it's hang.
So is it possible to "catch" msiexec
progress and for example update a progressbar on my app? Sounds crazy, but I'm pretty sure that some professional installer works this way running external msi package.
So, is it possibile? Is there something we can do in C# or is it a very hard task that requires a lot of knowledge I don't have?
Just a note: I know I could use "/qb"
param, but some package is not behaving the correct way with it and I don't want to use it.
回答1:
You probably will have to consume Windows Installer API directly if you want to monitor progress,
http://www.codeproject.com/Articles/5773/Wrapping-the-Windows-Installer-2-0-API
This CodeProject article shows a sample, while Microsoft has little information about the functions on MSDN,
http://msdn.microsoft.com/en-us/library/windows/desktop/aa370384(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa368786(v=vs.85).aspx
回答2:
instead of this
So is it possible to "catch" msiexec progress and for example update a progressbar on my app?
you can have a normal progresBar
that will keep running until the task has been done
something like this
myProgressBar.Style = ProgressBarStyle.Marquee;
from Marquee also check msdn.microsoft.com
![](https://www.eimg.top/images/2020/03/24/82193f89db573f471fede7e2203f7bff.jpg)
1.Keep a check if msiexec
is running
2.start the myProgressBar.Style = ProgressBarStyle.Marquee;
3.Keep running
![](https://www.eimg.top/images/2020/03/24/81359d4df35b647de5907dd7ef390555.jpg)
4.If msiexec
has finished then hide the progresBar
来源:https://stackoverflow.com/questions/10811323/msiexec-progress-catch