c#调用exe捕获返回值

匿名 (未验证) 提交于 2019-12-03 00:22:01

c#源码例子如下:

 private void ProgressCheck(object sender, EventArgs e)         {             string strCheck = System.Environment.CurrentDirectory + "\\ProgressCheck\\ProgressCheck.exe";             string TaskPollExePath = System.Environment.CurrentDirectory + "\\TaskPoll.exe";             string CreFusXmlExePath = System.Environment.CurrentDirectory + "\\CreFusXml.exe";             string CoordConvertTaskExePath = System.Environment.CurrentDirectory + "\\CoordCvt\\CoordConvertTask.exe";             string GCSConvertExePath = System.Environment.CurrentDirectory + "\\CoordCvt\\GCSConvert.exe";             string CreFusCheckPrjExePath = System.Environment.CurrentDirectory + "\\FusCheck\\CreFusCheckPrj.exe";             string ProTskExePath = System.Environment.CurrentDirectory + "\\FusCheck\\TskExe\\ProTsk.exe";             string MDomSupQuaChkExePath = System.Environment.CurrentDirectory + "\\FusCheck\\KnlExe\\MDomSupQuaChk.exe";              Process process1 = CreateProcessTasks(strCheck, TaskPollExePath, true);             process1.Start();             process1.WaitForExit();             if (process1.ExitCode!= 0)             {                 MessageBox.Show(TaskPollExePath, "程序异常");                 return;             }              Process process2 = CreateProcessTasks(strCheck, CreFusXmlExePath, true);             process2.Start();             process2.WaitForExit();             if (process2.ExitCode != 0)             {                 MessageBox.Show(CreFusXmlExePath, "程序异常");                 return;             }              Process process3 = CreateProcessTasks(strCheck, CoordConvertTaskExePath, true);             process3.Start();             process3.WaitForExit();             if (process3.ExitCode != 0)             {                 MessageBox.Show(CoordConvertTaskExePath, "程序异常");                 return;             }              Process process4 = CreateProcessTasks(strCheck, GCSConvertExePath, true);             process4.Start();             process4.WaitForExit();             if (process4.ExitCode != 0)             {                 MessageBox.Show(GCSConvertExePath, "程序异常");                 return;             }              Process process5 = CreateProcessTasks(strCheck, CreFusCheckPrjExePath, true);             process5.Start();             process5.WaitForExit();             if (process5.ExitCode != 0)             {                 MessageBox.Show(CreFusCheckPrjExePath, "程序异常");                 return;             }              Process process6 = CreateProcessTasks(strCheck, ProTskExePath, true);             process6.Start();             process6.WaitForExit();             if (process6.ExitCode != 0)             {                 MessageBox.Show(ProTskExePath, "程序异常");                 return;             }              Process process7 = CreateProcessTasks(strCheck, MDomSupQuaChkExePath, true);             process7.Start();             process7.WaitForExit();             if (process7.ExitCode != 0)             {                 MessageBox.Show(MDomSupQuaChkExePath, "程序异常");                 return;             }              MessageBox.Show("程序无异常","提示");             return;         }          private Process CreateProcessTasks(string exe_path, string str_arguments, bool b_create_win = true)         {             Process process = new System.Diagnostics.Process();             process.StartInfo.FileName = exe_path;             process.StartInfo.Arguments = str_arguments;             process.StartInfo.UseShellExecute = false;             process.StartInfo.RedirectStandardInput = false;  //true             process.StartInfo.RedirectStandardOutput = false;  //true             process.StartInfo.RedirectStandardError = false;             process.StartInfo.CreateNoWindow = b_create_win;             //process.Start();             return process;         }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!