无声安装

我正在使用C#编写一个InstallerClass作为我的安装程序的自定义操作,我可以使用InstallerClass成功运行外部exe(安装),但是当我尝试在InstallerClass使用/quiet时,它不会安装exe。 但是我可以在命令提示符下使用/quiet以静默方式成功安装它。

是否有任何原因或者如何使用C#以静默模式安装?

以下是我在Commit方法中使用的代码(overriden):

 Process p = new Process(); p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = pathExternalInstaller; p.StartInfo.Arguments = "/quiet"; p.Start(); 

这是我用来做一个安静的安装和卸载:

  public static bool RunInstallMSI(string sMSIPath) { try { Console.WriteLine("Starting to install application"); Process process = new Process(); process.StartInfo.FileName = "msiexec.exe"; process.StartInfo.Arguments = string.Format(" /qb /i \"{0}\" ALLUSERS=1", sMSIPath); process.Start(); process.WaitForExit(); Console.WriteLine("Application installed successfully!"); return true; //Return True if process ended successfully } catch { Console.WriteLine("There was a problem installing the application!"); return false; //Return False if process ended unsuccessfully } } public static bool RunUninstallMSI(string guid) { try { Console.WriteLine("Starting to uninstall application"); ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe", string.Format("/c start /MIN /wait msiexec.exe /x {0} /quiet", guid)); startInfo.WindowStyle = ProcessWindowStyle.Hidden; Process process = Process.Start(startInfo); process.WaitForExit(); Console.WriteLine("Application uninstalled successfully!"); return true; //Return True if process ended successfully } catch { Console.WriteLine("There was a problem uninstalling the application!"); return false; //Return False if process ended unsuccessfully } } 

这对我有用。

 Process process = new Process(); process.StartInfo.FileName = @ "C:\PATH\Setup.exe"; process.StartInfo.Arguments = "/quiet"; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.Start(); process.WaitForExit(); 

您是否尝试使用安装参数中列出的/Q/QB参数? 它可能看起来像这样:

p.StartInfo.Arguments = "/Q";

我从这个文档中得到了这个: http : //msdn.microsoft.com/en-us/library/ms144259(v = sql.100).aspx