AcManager.Tools.GameProperties.GameCommandExecutorBase.Execute C# (CSharp) Метод

Execute() защищенный Метод

protected Execute ( string command ) : void
command string
Результат void
        protected void Execute(string command) {
            if (string.IsNullOrWhiteSpace(command)) return;

            command = VariablesReplacement.Process(command, _properties, null);
            Logging.Write($"Executing command: “{command}”");

            try {
                var proc = Process.Start(new ProcessStartInfo {
                    FileName = "cmd",
                    Arguments = $"/C \"{command}\"",
                    UseShellExecute = false,
                    WorkingDirectory = FileUtils.GetDocumentsDirectory(),
                    RedirectStandardOutput = true,
                    RedirectStandardError = true,
                });

                if (proc == null) {
                    throw new Exception(ToolsStrings.GameCommand_UnknownProblem);
                }

                proc.OutputDataReceived += Process_OutputDataReceived;
                proc.ErrorDataReceived += Process_ErrorDataReceived;

                proc.BeginOutputReadLine();
                proc.BeginErrorReadLine();
                
                if (!proc.WaitForExit(OptionCommandTimeout)) {
                    proc.Kill();
                    throw new InformativeException(ToolsStrings.GameCommand_TimeoutExceeded,
                            string.Format(ToolsStrings.GameCommand_TimeoutExceeded_Commentary, (double)OptionCommandTimeout / 1000));
                }
            } catch (Exception e) {
                NonfatalError.Notify(ToolsStrings.GameCommand_CannotExecute, e);
            }
        }