我通过C#wpf表单运行msi安装程序。我想查看信息安装信息。如何显示安装信息?或者我该如何每秒更新一次文字?
例如:安装。安装...安装...
public void install_uninstall(string _targetIpAddress)
{
//string _targetIpAddress = (string)PC;
string[] directum = { "1.msi", "2.msi", "3.msi" };
string retVal = "";
ConnectionOptions options = new ConnectionOptions();
//options.Username = @"domain\username";
//options.Password = "password";
ManagementScope scope = new ManagementScope(("\\\\" + _targetIpAddress + "\\root\\cimv2"), options);
scope.Connect();
ManagementObjectSearcher searcher;
SelectQuery query;
EnumerationOptions enumOptions;
ManagementPath p = new ManagementPath("Win32_Product");
ManagementClass classInstance = new ManagementClass(scope, p, null);
ManagementBaseObject inParams = classInstance.GetMethodParameters("Install");
ManagementBaseObject outParams;
inParams["AllUsers"] = true;
inParams["Options"] = string.Empty;
if (programs.Contains("1"))
{
thisTime = DateTime.Now;
percent = 100 / 6F;
Dispatcher.BeginInvoke(new ThreadStart(delegate { text_install.Document.Blocks.Add(new Paragraph(new Run(thisTime + " Удаление..."))); ProgressBar.IsIndeterminate = false; PercentText.Visibility = Visibility.Visible; }));
thisTime = DateTime.Now;
Dispatcher.BeginInvoke(new ThreadStart(delegate { text_install.Document.Blocks.Add(new Paragraph(new Run(thisTime + " Установка..."))); }));
foreach (var item in dir)
{
inParams["PackageLocation"] = @"\\" + _targetIpAddress + @"\d$\Dir\" + item;
outParams = classInstance.InvokeMethod("Install", inParams, null);
retVal = outParams["ReturnValue"].ToString();
retVal_install(dir, inParams, retVal, item);
}
}