MsiExec progress catch

半腔热情 提交于 2019-12-21 06:18:30

问题


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

1.Keep a check if msiexec is running

2.start the myProgressBar.Style = ProgressBarStyle.Marquee;

3.Keep running

4.If msiexec has finished then hide the progresBar



来源:https://stackoverflow.com/questions/10811323/msiexec-progress-catch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!