using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Install.Core.Common
{
    public static class CMD
    {
        public static void RunExe(string exePath, string arguments, out string output, out string error)
        {
            using (Process process = new Process())
            {
                process.StartInfo.FileName = exePath;
                process.StartInfo.Arguments = arguments;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow = true;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError = true;
                process.Start();

                output = process.StandardOutput.ReadToEnd();
                error = process.StandardError.ReadToEnd();

                process.WaitForExit();
                process.Close();
            }
        }

        public static void RunExe(string exePath)
        {
            Process startProc = new Process();
            startProc.StartInfo.FileName = exePath;  //就是你要打开的文件的详细路径
            startProc.StartInfo.UseShellExecute = true;
           
            startProc.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(exePath); //就是如APGIS.Tools.exe 执行文件是在那个文件夹下。
            startProc.Start();
        }
    }
}
