public Dictionary <string, string> RunCommandLine(string commandLine, string stdIn) { Dictionary <string, string> output = new Dictionary <string, string>(); AsyncProcessStream processStream = new AsyncProcessStream(commandLine); try { processStream.Start(); output["pid"] = processStream.process.Id.ToString(); if (stdIn != null) { processStream.Write(stdIn); processStream.Write("\r\n"); // write everything and then close the input processStream.process.StandardInput.Close(); } processStream.WaitForExit(); output["stdout"] = processStream.GetOutput(); } catch (System.InvalidOperationException e) { //TODO: e.ToString(); } catch (System.ComponentModel.Win32Exception e) { //TODO: e.ToString(); into dictionary } return(output); }
public Dictionary <string, string> OpenShell() { if (shell == null) { shell = new AsyncProcessStream("cmd"); shell.Start(); Thread.Sleep(50); } Dictionary <string, string> output = new Dictionary <string, string>(); output["pid"] = shell.process.Id.ToString(); return(output); }