我遇到了Windows更新靜默安裝的小問題。 爲什麼我需要它?我有一個系統磁盤的副本,我用來重新安裝win7(利用.net框架,Visual Studio,Java和50多個其他應用程序安裝一次)。 然後我需要安裝一些重要的更新。我編碼在c#中的小utillity,工作正常,除了 安裝不沉默,即使使用startInfo.Arguments = "/quiet/norestart/passive";
。 不沉默:我的意思是至少有兩個窗口,如問我是否需要安裝或重新啓動選項。無聲安裝.msu Windows更新?
問題在另一個論壇發言How are people deploying HOTFIXES .msu files? 但解決方案有點不清楚。有人知道如何解決它嗎? 再次,startInfo.Arguments = "/quiet/norestart/passive";
或startInfo.Arguments = @"/qb!"+ "REBOOT=ReallySuppress"+ @"/qn";
不工作,並在鏈接解釋爲什麼。 textBox1.Text
是所有修補程序和更新在一個目錄中的位置。
{
string[] filePaths = Directory.GetFiles(textBox1.Text);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = true;
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
//startInfo.Arguments = "/quiet/norestart/passive";
for (int i = 0; i < filePaths.Length; i++)
{
label1.Text = "Working";
startInfo.FileName = filePaths[i];
startInfo.Arguments = @"/qb!"+ "REBOOT=ReallySuppress"+ @"/qn";
try
{
Process.Start(startInfo.FileName).WaitForExit();
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
label1.Text = " Done ";
}
爲什麼使用逐字字符串文字不需要? '/'不是C#中的轉義字符。 – Joey