Пример #1
0
        /// <summary>
        /// In some cases you must catch huge outputs, otherwise you shell will fail.
        /// This method executes CMD commands, captures all outputs (stdout and stderr, not only stdin)
        ///  and passes them to your shell.
        /// </summary>
        /// <param name="cmdCommands">CMD commands to be executed separated. Multi or a single line.</param>
        /// <param name="throwExceptions">Throw an exceptions in case of a non-zero exit code or exceeding the duration limit.</param>
        /// <param name="collectOutputs">Instructs to collect all console outputs.</param>
        /// <param name="outputWaitLimit">The maximum duration limit for any output waiting from a CMD-shell. Default is 15 minutes.</param>
        public int ExecAndShowCatched(string cmdCommands, bool throwExceptions = false, bool collectOutputs = false, TimeSpan?outputWaitLimit = null)
        {
            var exitCode = new OutputCatcher(cmdCommands, throwExceptions, collectOutputs, outputWaitLimit)
                           .Exec();

            return(exitCode);
        }
Пример #2
0
        /// <summary>
        /// In some cases you must catch huge outputs, otherwise you shell will fail.
        /// This method executes CMD commands, captures all outputs (stdout and stderr, not only stdin)
        ///  and passes them to your shell.
        /// </summary>
        /// <param name="cmdCommands">CMD commands to be executed separated. Multi or a single line.</param>
        /// <param name="outputCombined">Combined CMD outputs of stdout and stderr.</param>
        /// <param name="throwExceptions">Throw an exceptions in case of a non-zero exit code or exceeding the duration limit.</param>
        /// <param name="outputWaitLimit">The maximum duration limit for any output waiting from a CMD-shell. Default is 15 minutes.</param>
        public int ExecAndShowCatched(string cmdCommands, out StringBuilder outputCombined, bool throwExceptions = false, TimeSpan?outputWaitLimit = null)
        {
            var outputer = new OutputCatcher(cmdCommands, throwExceptions, true, outputWaitLimit);
            var exitCode = outputer.Exec();

            outputCombined = outputer.OutputCombined;

            return(exitCode);
        }