1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| public void ExecuteWithOutput(string path, string exeName) { try { if (!System.IO.File.Exists(path + exeName + "\\" + exeName + ".exe")) { xErrorOutException(new Exception("请确认" + exeName + "文件路径配置是否正确")); return; } using (System.Diagnostics.Process cmdProcess = new System.Diagnostics.Process()) { System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); psi.UseShellExecute = false; psi.RedirectStandardInput = true; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; psi.CreateNoWindow = true; psi.FileName = path + exeName + "\\" + exeName + ".exe"; psi.WorkingDirectory = path + exeName + "\\"; cmdProcess.StartInfo = psi; cmdProcess.Start(); cmdProcess.WaitForExit(); cmdProcess.Dispose(); } } catch(Exception ex) { xErrorOutException(ex); } }
|