public static CommandLineResult Run(ProcessStartInfo processStartInfo, CommandLineRunOptions options)
        {
            const int ErrorIsException = -32767;

            var output = string.Empty;
            var error = string.Empty;
            var exitCode = 0;

            try
            {
                using (var process = Process.Start(processStartInfo))
                {
                    process.WaitForExit();

                    output = process.StandardOutput.ReadToEnd();
                    error = process.StandardError.ReadToEnd();
                    exitCode = process.ExitCode;
                }
            }
            catch (Exception e)
            {
                if (options != CommandLineRunOptions.TreatExceptionsAsErrors)
                {
                    throw e;
                }

                error = e.ToString();
                exitCode = ErrorIsException;
            }

            return new CommandLineResult
            {
                Output = output,
                Error = error,
                ExitCode = exitCode
            };
        }
            public For_execution_with_run_option()
            {
                this.options = CommandLineRunOptions.None;

                this.program = new CommandLineProgram(
                    () => new ProcessStartInfo(),
                    (info, opt) => {
                        this.options = opt;
                        return null;
                    });
            }
        public CommandLineResult Execute(string filename, CommandLineRunOptions runOptions)
        {
            ProcessStartInfo info = this.PrepareFunction()
                .WithFileName(filename);

            return this.Execute(info, runOptions);
        }
        public CommandLineResult Execute(ProcessStartInfo processStartInfo, CommandLineRunOptions runOptions)
        {
            if (this.Executing != null)
            {
                this.Executing(this, new CommandLineProgramEventArgs
                {
                    ProcessStartInfo = processStartInfo
                });
            }

            CommandLineResult result = this.RunFunction(processStartInfo, runOptions);

            if (this.Executed != null)
            {
                this.Executed(this, new CommandLineProgramEventArgs
                {
                    ProcessStartInfo = processStartInfo
                });
            }

            return result;
        }