private void RunDFUProcess(string arguments) { var p = WinProcessUtil.StartNewProcess(); p.StartInfo.FileName = @"dfu.exe"; p.StartInfo.Arguments = arguments; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardOutput = true; p.OutputDataReceived += new DataReceivedEventHandler((sender, e) => HandleOutputData(e.Data)); p.ErrorDataReceived += new DataReceivedEventHandler((sender, e) => HandleOutputData(e.Data)); p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); p.WaitForExit(); if (p.ExitCode != 0) { var errorString = string.Format("Process: {0}, args: {1} exited with non-zero code", p.StartInfo.FileName, p.StartInfo.Arguments); LogUtil.LogEvent(errorString); throw new InvalidOperationException(errorString); } }
public override ICommandResult Execute(IDictionary <string, string> vars, params string[] args) { if (args.Length < 1) { return(Error("exec command can't be used without arguments (at least tool name must be specified)")); } SubstituteVariables(vars, args); var exePath = Path.Combine(@".\bin\", args[0]); string argsString = string.Join(" ", args.Skip(1).ToArray()); var processStartInfo = new ProcessStartInfo() { FileName = exePath, Arguments = argsString, WindowStyle = ProcessWindowStyle.Hidden, WorkingDirectory = SafeDirectory.GetCurrentDirectory(), }; LogUtil.LogEvent(string.Format("Running process: {0}, args: {1} ", processStartInfo.FileName, processStartInfo.Arguments)); var p = WinProcessUtil.StartNewProcess(processStartInfo); p.WaitForExit(); if (p.ExitCode != 0) { return(Error(string.Format("Process: {0}, args: {1} exited with non-zero code", p.StartInfo.FileName, p.StartInfo.Arguments))); } return(Success()); }
private void RunTether() { RestoreDfuAndTetherFiles(); SafeDirectory.SetCurrentDirectory(MiscUtils.BIN_DIRECTORY); LogUtil.LogEvent("Tether process starting"); var p = WinProcessUtil.StartNewProcess(); p.StartInfo.FileName = @"tether.exe"; var files = new List <string>(); if (File.Exists(MiscUtils.IBSS_FILE_NAME)) { files.Add(MiscUtils.IBSS_FILE_NAME); } if (File.Exists(MiscUtils.IBEC_FILE_NAME)) { files.Add(MiscUtils.IBEC_FILE_NAME); } if (File.Exists(MiscUtils.KERNEL_CACHE_FILE_NAME)) { files.Add(MiscUtils.KERNEL_CACHE_FILE_NAME); } string arguments = string.Join(" ", files); p.StartInfo.Arguments = arguments; p.StartInfo.UseShellExecute = false; p.StartInfo.CreateNoWindow = true; p.StartInfo.WorkingDirectory = SafeDirectory.GetCurrentDirectory(); p.StartInfo.RedirectStandardError = true; p.StartInfo.RedirectStandardOutput = true; p.OutputDataReceived += (sender, e) => HandleOutputData(e.Data); p.ErrorDataReceived += (sender, e) => HandleOutputData(e.Data); p.Start(); p.BeginOutputReadLine(); p.BeginErrorReadLine(); p.WaitForExit(); if (p.ExitCode != 0) { var errorString = string.Format("Process: {0}, args: {1} exited with non-zero code", p.StartInfo.FileName, p.StartInfo.Arguments); LogUtil.LogEvent(errorString); throw new InvalidOperationException(errorString); } }