Beispiel #1
0
        /// <summary>
        /// Executes an 'adb shell' command, writing output asynchonously to the console window.
        /// </summary>
        /// <param name="Command">The command to execute ('shell' will be prepended)</param>
        /// <param name="Console">The fmMain object to write output to</param>
        /// <returns>
        /// The output of the command (stderr on failure, stdout on success)
        /// </returns>
        public static string ExecuteShellCommandWithOutput(string Command, fmMain Console)
        {
            string output;

            _console = Console;

            ProcessStartInfo info = CreateAdbStartInfo("shell " + Command);

            Process proc = new Process();

            proc.StartInfo           = info;
            proc.OutputDataReceived += new DataReceivedEventHandler(proc_OutputDataReceived);
            proc.Start();

            proc.BeginOutputReadLine();

            proc.WaitForExit();

            string stdErr = proc.StandardError.ReadToEnd();

            output = !String.IsNullOrEmpty(stdErr) ? "Error: " + stdErr : "";

            return(output);
        }
Beispiel #2
0
 public CommandManager(fmMain Parent)
 {
     _parent = Parent;
 }
Beispiel #3
0
 public AdbCommand(fmMain Console)
 {
     _console = Console;
 }
Beispiel #4
-1
        /// <summary>
        /// Executes a partitioning command, throwing a PartitionException if an error occurs
        /// </summary>
        /// <param name="Command">The command to execute</param>
        /// <param name="console">A fmMain object to write output to</param>
        public static void ExecutePartitionCommand(string Command, fmMain console)
        {
            string output = null;

            Process proc = Process.Start(CreateAdbStartInfo("shell " + Command));

            proc.WaitForExit();

            string stdErr = proc.StandardError.ReadToEnd();

            if (!String.IsNullOrEmpty(stdErr))
            {
                throw new PartitionException(stdErr);
            }

            output = proc.StandardOutput.ReadToEnd();

            if (!String.IsNullOrEmpty(output))
            {
                console.WriteToConsole(output.Replace("\r", ""));
            }
        }