Example #1
0
        public static void Run(string exePath, string args)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo(exePath);

            startInfo.Arguments              = args;
            startInfo.CreateNoWindow         = true;  //不显示Dos窗口
            startInfo.UseShellExecute        = false; //是否指定操作系统外壳进程启动程序
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardInput  = true;

            Process p = Process.Start(startInfo);

            StreamReader reader = p.StandardOutput;

            do
            {
                string lineStr = reader.ReadLine();
                CmdHelp.PutResultThreadToUI(lineStr);
            }while (!reader.EndOfStream);

            p.WaitForExit();
            reader.Close();
            p.Close();
        }
Example #2
0
 //收到错误数据
 static void p_ErrorDataReceived(object sender, DataReceivedEventArgs e)
 {
     CmdHelp.PutResultThreadErrorToUI(e.Data);
 }
Example #3
0
 //收到数据
 static void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
 {
     CmdHelp.PutResultThreadToUI(e.Data);
 }