using System.Diagnostics; using System.Linq; namespace Update.Util { /// /// 进程工具 /// public static class ProcessUtil { /// /// 运行指定程序,可指定命令行参数 /// /// 要运行的程序路径 /// 命令行参数数组 /// 如果启动了进程资源,则为 true;如果没有启动新的进程资源(例如,如果重用了现有进程),则为 false。 public static bool Start(string fileName, params string[] args) { Process process = new Process(); process.StartInfo.FileName = fileName; if (args != null) process.StartInfo.Arguments = string.Join(" ", args.Select(arg => "\"" + arg + "\"")); process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.CreateNoWindow = true; return process.Start(); } } }