【发布时间】:2012-06-05 10:34:06
【问题描述】:
我遇到了 Windows 更新静默安装的小问题。
为什么我需要它?我有用于重新安装 win7 的系统磁盘的位副本(利用 .net 框架、Visual Studio、Java 和 50 多个其他应用程序一次安装)。
然后我需要安装一些重要的更新。我在 c# 中编写了小型实用程序,工作正常,除了
即使使用 startInfo.Arguments = "/quiet/norestart/passive";,安装也不会静默。
不沉默:我的意思是至少有两个窗口询问我是否需要安装或重新启动选项。
问题在另一个论坛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# 中的转义字符。
标签: c# windows installation updates silent