void AttemptProcessExecution(CommandArguments arguments) { try { ProcessIOActive = false; //check for executable programs matching that name Process = new Process(); ProcessStartInfo info = Process.StartInfo; info.UseShellExecute = false; info.RedirectStandardInput = true; info.RedirectStandardOutput = true; info.RedirectStandardError = true; info.FileName = arguments.Command.Argument; info.Arguments = arguments.GetQuotedArguments(); info.WindowStyle = ProcessWindowStyle.Hidden; info.CreateNoWindow = true; Process.Start(); StandardOutputReader = new AsynchronousReader(this, HandleStandardOutputRead, Process.StandardOutput); StandardErrorReader = new AsynchronousReader(this, HandleStandardErrorRead, Process.StandardError); new Thread(ProcessTerminationCheckThread).Start(); ProcessIOActive = true; } catch (System.ComponentModel.Win32Exception exception) { Process = null; ProcessIOActive = false; PrintError(exception.Message); PromptAndSelect(); } }
public void Execute(CommandArguments arguments) { string command = arguments.Command.Argument; if (CommandHandlerDictionary.ContainsKey(command)) { CommandHandler handler = CommandHandlerDictionary[command]; if (handler.ArgumentCount != -1 && arguments.Arguments.Length != handler.ArgumentCount) { PrintError("Invalid argument count."); PrintLine(handler.Usage()); } else handler.Function(arguments.GetArgumentString()); PromptAndSelect(); } else { if (ProgramConfiguration.Aliases.ContainsKey(command)) { string aliasLine = ProgramConfiguration.Aliases[command] + " " + arguments.GetQuotedArguments(); Execute(aliasLine); } else { if (PerformChangeDirectoryCheck(arguments.Command.Argument)) return; AttemptProcessExecution(arguments); return; } } }