private void InitializeConEmuRunner() { ConEmuConsole.RunningSession?.CloseConsoleEmulator(); var config = new XmlDocument(); config.Load(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), @"Style\ConEmu.xml")); // normally I'd import a module here... var startupCommand = $"powershell.exe -NoProfile -NoExit –ExecutionPolicy Bypass"; var startInfo = new ConEmuStartInfo { IsEchoingConsoleCommandLine = true, IsElevated = true, ConsoleProcessCommandLine = startupCommand, BaseConfiguration = config, WhenConsoleProcessExits = WhenConsoleProcessExits.KeepConsoleEmulator }; var count = 0; // trying to deal wtih the CloseConsole being slow? while (ConEmuConsole.RunningSession != null && count < 100) { ConEmuConsole.RunningSession?.CloseConsoleEmulator(); Thread.Sleep(10); count++; } ConEmuConsole.Start(startInfo); }
public override void StartProcess(string command, string arguments, string workdir) { var cmdl = new StringBuilder(); if (command != null) { cmdl.Append(command.Quote() /* do the escaping for it */); cmdl.Append(" "); } cmdl.Append(arguments /* expecting to be already escaped */); var startinfo = new ConEmuStartInfo(); startinfo.ConsoleProcessCommandLine = cmdl.ToString(); startinfo.ConsoleProcessExtraArgs = " -cur_console:P:\"<Solarized Light>\""; startinfo.StartupDirectory = workdir; startinfo.WhenConsoleProcessExits = WhenConsoleProcessExits.KeepConsoleEmulatorAndShowMessage; startinfo.AnsiStreamChunkReceivedEventSink = (sender, args) => FireDataReceived(new TextEventArgs(args.GetText(GitModule.SystemEncoding))); startinfo.ConsoleProcessExitedEventSink = (sender, args) => { _nLastExitCode = args.ExitCode; FireProcessExited(); }; startinfo.ConsoleEmulatorClosedEventSink = (s, e) => { if (s == _terminal.RunningSession) { FireTerminated(); } }; startinfo.IsEchoingConsoleCommandLine = true; _terminal.Start(startinfo); }
public override void StartProcess(string command, string arguments, string workDir, Dictionary <string, string> envVariables) { ProcessOperation operation = CommandLog.LogProcessStart(command, arguments, workDir); try { var commandLine = new ArgumentBuilder { command.Quote(), arguments }.ToString(); var outputProcessor = new ConsoleCommandLineOutputProcessor(commandLine.Length, FireDataReceived); var startInfo = new ConEmuStartInfo { ConsoleProcessCommandLine = commandLine, IsEchoingConsoleCommandLine = true, WhenConsoleProcessExits = WhenConsoleProcessExits.KeepConsoleEmulatorAndShowMessage, AnsiStreamChunkReceivedEventSink = outputProcessor.AnsiStreamChunkReceived, StartupDirectory = workDir }; foreach (var(name, value) in envVariables) { startInfo.SetEnv(name, value); } startInfo.ConsoleProcessExitedEventSink = (_, args) => { _nLastExitCode = args.ExitCode; operation.LogProcessEnd(_nLastExitCode); outputProcessor.Flush(); FireProcessExited(); }; startInfo.ConsoleEmulatorClosedEventSink = (sender, _) => { Validates.NotNull(_terminal); if (sender == _terminal.RunningSession) { FireTerminated(); } }; Validates.NotNull(_terminal); _terminal.Start(startInfo, ThreadHelper.JoinableTaskFactory, AppSettings.ConEmuStyle.Value, AppSettings.ConEmuFontSize.Value); } catch (Exception ex) { operation.LogProcessEnd(ex); throw; } }
public override void StartProcess(string command, string arguments, string workdir, Dictionary <string, string> envVariables) { var cmdl = new StringBuilder(); if (command != null) { cmdl.Append(command.Quote() /* do the escaping for it */); cmdl.Append(" "); } cmdl.Append(arguments /* expecting to be already escaped */); var startinfo = new ConEmuStartInfo(); startinfo.ConsoleProcessCommandLine = cmdl.ToString(); if (AppSettings.ConEmuStyle.ValueOrDefault != "Default") { startinfo.ConsoleProcessExtraArgs = " -new_console:P:\"" + AppSettings.ConEmuStyle.ValueOrDefault + "\""; } startinfo.StartupDirectory = workdir; foreach (var(name, value) in envVariables) { startinfo.SetEnv(name, value); } startinfo.WhenConsoleProcessExits = WhenConsoleProcessExits.KeepConsoleEmulatorAndShowMessage; var outputProcessor = new ConsoleCommandLineOutputProcessor(startinfo.ConsoleProcessCommandLine.Length, FireDataReceived); startinfo.AnsiStreamChunkReceivedEventSink = outputProcessor.AnsiStreamChunkReceived; startinfo.ConsoleProcessExitedEventSink = (sender, args) => { outputProcessor.Flush(); _nLastExitCode = args.ExitCode; FireProcessExited(); }; startinfo.ConsoleEmulatorClosedEventSink = (s, e) => { if (s == _terminal.RunningSession) { FireTerminated(); } }; startinfo.IsEchoingConsoleCommandLine = true; _terminal.Start(startinfo); }
private void setupConEmu() { ConEmuStartInfo startInfo = new ConEmuStartInfo(); startInfo.ConEmuExecutablePath = @"C:\Program Files\ConEmu\ConEmu64.exe"; startInfo.GreetingText = $"ConEmu version [{FileVersionInfo.GetVersionInfo(_conEmuPath).ProductVersion}]"; startInfo.GreetingText += $"ngrok version [{FileVersionInfo.GetVersionInfo(_ngrokPath).ProductVersion}"; startInfo.ConsoleProcessCommandLine = _ngrokPath + " start --none"; _control = new ConEmuControl(); _session = _control.Start(startInfo); pnlBottom.Controls.Add(_control); _control.Dock = DockStyle.Fill; _control.Enabled = false; }
public override void StartProcess(string command, string arguments, string workdir, Dictionary <string, string> envVariables) { var cmdl = new StringBuilder(); if (command != null) { cmdl.Append(command.Quote() /* do the escaping for it */); cmdl.Append(" "); } cmdl.Append(arguments /* expecting to be already escaped */); var startinfo = new ConEmuStartInfo(); startinfo.ConsoleProcessCommandLine = cmdl.ToString(); if (AppSettings.ConEmuStyle.ValueOrDefault != "Default") { startinfo.ConsoleProcessExtraArgs = " -new_console:P:\"" + AppSettings.ConEmuStyle.ValueOrDefault + "\""; } startinfo.StartupDirectory = workdir; foreach (var envVariable in envVariables) { startinfo.SetEnv(envVariable.Key, envVariable.Value); } startinfo.WhenConsoleProcessExits = WhenConsoleProcessExits.KeepConsoleEmulatorAndShowMessage; startinfo.AnsiStreamChunkReceivedEventSink = (sender, args) => { var text = args.GetText(GitModule.SystemEncoding); if (EnvUtils.RunningOnWindows()) { text = text.Replace("\n", Environment.NewLine); } FireDataReceived(new TextEventArgs(text)); }; startinfo.ConsoleProcessExitedEventSink = (sender, args) => { _nLastExitCode = args.ExitCode; FireProcessExited(); }; startinfo.ConsoleEmulatorClosedEventSink = (s, e) => { if (s == _terminal.RunningSession) { FireTerminated(); } }; startinfo.IsEchoingConsoleCommandLine = true; _terminal.Start(startinfo); }
public override void StartProcess(string command, string arguments, string workDir, Dictionary <string, string> envVariables) { var commandLine = new ArgumentBuilder { command.Quote(), arguments }.ToString(); var outputProcessor = new ConsoleCommandLineOutputProcessor(commandLine.Length, FireDataReceived); var startInfo = new ConEmuStartInfo { ConsoleProcessCommandLine = commandLine, IsEchoingConsoleCommandLine = true, WhenConsoleProcessExits = WhenConsoleProcessExits.KeepConsoleEmulatorAndShowMessage, AnsiStreamChunkReceivedEventSink = outputProcessor.AnsiStreamChunkReceived, StartupDirectory = workDir }; if (AppSettings.ConEmuStyle.ValueOrDefault != "Default") { startInfo.ConsoleProcessExtraArgs = " -new_console:P:\"" + AppSettings.ConEmuStyle.ValueOrDefault + "\""; } foreach (var(name, value) in envVariables) { startInfo.SetEnv(name, value); } var operation = CommandLog.LogProcessStart(command, arguments); startInfo.ConsoleProcessExitedEventSink = (_, args) => { _nLastExitCode = args.ExitCode; operation.LogProcessEnd(_nLastExitCode); outputProcessor.Flush(); FireProcessExited(); }; startInfo.ConsoleEmulatorClosedEventSink = (sender, _) => { if (sender == _terminal.RunningSession) { FireTerminated(); } }; _terminal.Start(startInfo, ThreadHelper.JoinableTaskFactory); }
private void RunConEmuSession() { ThreadHelper.ThrowIfNotOnUIThread(); ProductEnvironment.Instance.ConEmu = new ConEmuControl { MinimumSize = new System.Drawing.Size(1, 1), Dock = System.Windows.Forms.DockStyle.Fill }; var info = new ConEmuStartInfo { ConEmuExecutablePath = ProductEnvironment.Instance.GetConEmuExecutable(), ConsoleProcessCommandLine = ProductEnvironment.Instance.GetDefaultTask() }; try { XmlDocument xml = new XmlDocument(); xml.Load(ProductEnvironment.Instance.GetConfigurationFile()); info.BaseConfiguration = xml; } catch (FileNotFoundException) { MessageBox.Show("ConEmu configuration file not found!" + Environment.NewLine + "ConEmu will be started with default settings.", "Information", MessageBoxButton.OK, MessageBoxImage.Information); } ProductEnvironment.Instance.ConEmu.Start(info); WfhConEmu.Child = ProductEnvironment.Instance.ConEmu; if (ProductEnvironment.Instance.ConEmu.RunningSession != null) { var session = ProductEnvironment.Instance.ConEmu.RunningSession; session.ConsoleEmulatorClosed += RunningSession_ConsoleEmulatorClosed; } ProductEnvironment.Instance.ConEmuToolWindowLoaded(); m_HasExited = false; }
public override void StartProcess(string command, string arguments, string workdir) { var cmdl = new CommandLineBuilder(); cmdl.AppendFileNameIfNotNull(command /* do the escaping for it */); cmdl.AppendSwitch(arguments /* expecting to be already escaped */); var startinfo = new ConEmuStartInfo(); startinfo.ConsoleProcessCommandLine = cmdl.ToString(); startinfo.StartupDirectory = workdir; startinfo.WhenConsoleProcessExits = WhenConsoleProcessExits.KeepConsoleEmulatorAndShowMessage; startinfo.AnsiStreamChunkReceivedEventSink = (sender, args) => FireDataReceived(new TextEventArgs(args.GetText(GitModule.SystemEncoding))); startinfo.ConsoleProcessExitedEventSink = (sender, args) => { _nLastExitCode = args.ExitCode; FireProcessExited(); }; startinfo.ConsoleEmulatorClosedEventSink = delegate { FireTerminated(); }; startinfo.IsEchoingConsoleCommandLine = true; _terminal.Start(startinfo); }