This method below allows me to run ONE dos command in a command prompt and output the result to a textbox.
That is all fine and good, but I don't want to have to exit. I want to be able to send multiple commands in one session, not one at a time, but still using .NET as I am now.
If I don't run the "exit" command - the proc.ReadStandardOutput.Re
adToEnd( ) stays in a "waiting" state and I never get to see the result of the command in the textBox window.
static extern bool SetForegroundWindow(IntPtr hWnd);
private void RunGitCommandLine(string command)
ProcessStartInfo psi = new ProcessStartInfo("cmd");
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.CreateNoWindow = true;
psi.RedirectStandardInput = true;
var proc = Process.Start(psi);
string s = proc.StandardOutput.ReadToEnd();
textBoxCommandResult.Text = s;