【问题标题】:Silent install of .msu windows updates?.msu Windows 更新的静默安装?
【发布时间】: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


【解决方案1】:

首先,您只是将没有空格的参数链接在一起,因此只传递了一个可能不起作用的参数。试试

startInfo.Arguments = "/qb! REBOOT=ReallySuppress /qn"

【讨论】:

  • 我做到了,另外还有 10 多种格式。问题不在于参数,否则 startInfo.Arguments = "/quiet/norestart/passive" 就足够了。见上面的链接。
  • 好的,我试过了,没有任何改变 - wuse 还在询问安装吗?重启?等
  • 但是“/quiet/norestart/passive”不起作用,MS 应用程序几乎总是需要开关之间的空格,即“/quiet /norestart /passive”
  • 是的,是的,我的错误,但这样仍然无法正常工作。我仍然有窗口要求用户输入。
【解决方案2】:

最后我使用纯 CMD 行绕过它。无窗口静默安装,例外情况除外。

private void button1_Click(object sender, EventArgs e)
    {
        string[] filePaths = Directory.GetFiles(textBox1.Text);
        Process process = new Process();
        process.StartInfo.FileName = "cmd.exe";
        process.StartInfo.CreateNoWindow = true;
        process.StartInfo.UseShellExecute = false;
        process.EnableRaisingEvents = false;

        for (int i = 0; i < filePaths.Length; i++)
        {
            if (i == 0) { label1.Text = "Working On first task"; }
            process.StartInfo.Arguments = "/C " + "@" + "\"" + filePaths[i] + "\"" + " /quiet /norestart";
            process.Start();
            process.WaitForExit();
            label1.Text = (100 * i / filePaths.Length).ToString() + " % is done"; 

        }
        label1.Text = "Done";

    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-07
    • 2016-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多