Process.WaitForExit挂起-但我仅重定向标准输入?

我正在尝试执行一个批处理脚本,该脚本在我想确认的最后包含一个暂停语句:

var psi = new ProcessStartInfo(path, arguments);
psi.RedirectStandardInput = true;
psi.UseShellExecute = false;
psi.WorkingDirectory = workDir;

var p = Process.Start(psi);
p.StandardInput.WriteLine();
p.WaitForExit();

However, this code hangs forever in WaitForExit although the process has already finished. I know that you have to read the buffer when redirecting standard output / error. Is there something special about redirecting standard input as well?

评论