簡體   English   中英

靜默安裝.msu Windows更新?

[英]Silent install of .msu windows updates?

我在Windows Update靜默安裝中遇到小問題。 我為什么需要它? 我有用於重新安裝win7的系統磁盤的位副本(利用.net框架,Visual Studio,Java和一次安裝的50多個其他應用程序的優勢)。 然后,我需要安裝一些重要的更新。 我在C#中編寫了小實用程序,可以正常工作,除非即使使用startInfo.Arguments = "/quiet/norestart/passive";也不會使安裝靜音startInfo.Arguments = "/quiet/norestart/passive"; 不沉默:我的意思是至少有兩個窗口,例如詢問我是否最終需要安裝或重啟選項。

在另一個論壇中談論的問題人們如何部署HOTFIXES .msu文件? 但是解決方案對我來說還不清楚。 有人知道如何解決嗎? 同樣, 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 ";

        }

首先,您只是將參數鏈接在一起而沒有空格,因此只傳遞了一個可能無效的參數。 嘗試

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

最后,我使用純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";

    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM