C#单个CMD进程的多个输入和输出
您好,我如何向应用程序已启动的cmd进程输入命令,以及如何将输出重定向回cmd进程。之后,我想再次输入我的输入C#单个CMD进程的多个输入和输出,c#,process,system.diagnostics,C#,Process,System.diagnostics,您好,我如何向应用程序已启动的cmd进程输入命令,以及如何将输出重定向回cmd进程。之后,我想再次输入我的输入 static void Main(string[] args) { ProcessStartInfo psi = new ProcessStartInfo(); psi.CreateNoWindow = false; psi.FileName = "cmd.exe"; ps
static void Main(string[] args)
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.CreateNoWindow = false;
psi.FileName = "cmd.exe";
psi.Arguments = "/k";
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.RedirectStandardInput = true;
Process p = new Process();
p.StartInfo = psi;
p.Start();
while(true)
{
p.StandardInput.WriteLine(Console.ReadLine());
Console.WriteLine(p.StandardOutput.ReadToEnd());
}
Console.Read();
}