S
stemp1ar
I am wondering if it possible to open a single process and run
multiple commands on that process and check standard error and
standard out after each command? Has anyone done something similar
and has an example?
I am expecting it would look something like below...
// Execute the first command
proc.StartInfo.FileName = @"cmd.exe";
proc.StartInfo.Arguments = @"dir";
proc.Start();
Console.WriteLine("Error Output: " + proc.StandardError.ReadToEnd());
Console.WriteLine("Standard Output: " +
proc.StandardOutput.ReadToEnd());
// Execute a second command
proc.StartInfo.FileName = @"cmd.exe";
proc.StartInfo.Arguments = @"cd foo";
proc.Start();
Console.WriteLine("Error Output: " + proc.StandardError.ReadToEnd());
Console.WriteLine("Standard Output: " +
proc.StandardOutput.ReadToEnd());
// Execute the third command
proc.StartInfo.FileName = @"cmd.exe";
proc.StartInfo.Arguments = @"dir";
proc.Start();
Console.WriteLine("Error Output: " + proc.StandardError.ReadToEnd());
Console.WriteLine("Standard Output: " +
proc.StandardOutput.ReadToEnd());
proc.WaitForExit();
Console.WriteLine("Exit Code: " + proc.ExitCode);
multiple commands on that process and check standard error and
standard out after each command? Has anyone done something similar
and has an example?
I am expecting it would look something like below...
// Execute the first command
proc.StartInfo.FileName = @"cmd.exe";
proc.StartInfo.Arguments = @"dir";
proc.Start();
Console.WriteLine("Error Output: " + proc.StandardError.ReadToEnd());
Console.WriteLine("Standard Output: " +
proc.StandardOutput.ReadToEnd());
// Execute a second command
proc.StartInfo.FileName = @"cmd.exe";
proc.StartInfo.Arguments = @"cd foo";
proc.Start();
Console.WriteLine("Error Output: " + proc.StandardError.ReadToEnd());
Console.WriteLine("Standard Output: " +
proc.StandardOutput.ReadToEnd());
// Execute the third command
proc.StartInfo.FileName = @"cmd.exe";
proc.StartInfo.Arguments = @"dir";
proc.Start();
Console.WriteLine("Error Output: " + proc.StandardError.ReadToEnd());
Console.WriteLine("Standard Output: " +
proc.StandardOutput.ReadToEnd());
proc.WaitForExit();
Console.WriteLine("Exit Code: " + proc.ExitCode);