使用C#静默安装

我正在编写一个使用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 } } 

P这适用于我:)

  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