C#调用cmd命令执行msi安装文件

来源:互联网 发布:艾力绅 知乎 家用 编辑:程序博客网 时间:2024/06/03 20:04
            string strInput = @"msiexec /i D:\Install.msi /qb";
            Process p = new Process();
            p.StartInfo.FileName = "cmd.exe";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow = true;
            p.Start();

            p.StandardInput.WriteLine(strInput + "&exit");
            p.StandardInput.AutoFlush = true;
            string strOuput = p.StandardOutput.ReadToEnd();

            p.WaitForExit();
            p.Close();


原创粉丝点击