Esempio n. 1
0
        private void shellControl1_CommandEntered(object sender, CommandEnteredEventArgs e)
        {
            string command = e.Command;

            if (command.Equals("switch", StringComparison.CurrentCultureIgnoreCase))
            {
                CobaltMode = !CobaltMode;
                return;
            }

            if (cobaltMode)
            {
                ProcessInternalCommand(command);
            }
            else 
            {
                ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe");
                startInfo.Arguments = "/C " + e.Command;
                startInfo.RedirectStandardError = true;
                startInfo.RedirectStandardOutput = true;
                startInfo.UseShellExecute = false;
                startInfo.CreateNoWindow = true;
                Process p = Process.Start(startInfo);
                string output = p.StandardOutput.ReadToEnd();
                string error = p.StandardError.ReadToEnd();

                p.WaitForExit();
                if (output.Length != 0)
                    Shell.WriteText(output);
                else if (error.Length != 0)
                    Shell.WriteText(error);
            }
        }
Esempio n. 2
0
        private void shellControl1_CommandEntered(object sender, CommandEnteredEventArgs e)
        {
            string command = e.Command;

            if (command.Equals("switch", StringComparison.CurrentCultureIgnoreCase))
            {
                CobaltMode = !CobaltMode;
                return;
            }

            if (cobaltMode)
            {
                ProcessInternalCommand(command);
            }
            else
            {
                ProcessStartInfo startInfo = new ProcessStartInfo("cmd.exe");
                startInfo.Arguments              = "/C " + e.Command;
                startInfo.RedirectStandardError  = true;
                startInfo.RedirectStandardOutput = true;
                startInfo.UseShellExecute        = false;
                startInfo.CreateNoWindow         = true;
                Process p      = Process.Start(startInfo);
                string  output = p.StandardOutput.ReadToEnd();
                string  error  = p.StandardError.ReadToEnd();

                p.WaitForExit();
                if (output.Length != 0)
                {
                    Shell.WriteText(output);
                }
                else if (error.Length != 0)
                {
                    Shell.WriteText(error);
                }
            }
        }