string path = @"C:\Program Files"
string cmd = string.Format("start \"\" \"{0}vcredist_x86.exe\" /wait /q /norestart", path);//路径加"xxx"
Runcmd(cmd);
/// <summary>
/// 运行CMD
/// </summary>
/// <param name="cmd"></param>
public static void Runcmd(string cmd)
{
//start /wait vcredist_x86.exe /q /norestart
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/c C:\\Windows\\System32\\cmd.exe";
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.UseShellExecute = false;
startInfo.Verb = "RunAs";
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process process = new Process();
process.StartInfo = startInfo;
process.Start();
process.StandardInput.WriteLine(cmd);
process.StandardInput.WriteLine("exit");
process.StandardInput.AutoFlush = true;
process.WaitForExit();
process.Close();
}
静默安装vcredist_x86.exe 目录带空格
最新推荐文章于 2019-03-17 20:23:30 发布