我使用以下代码:
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
process.StartInfo = startInfo;
process.Start(); // stuck here
using (StreamWriter writer = process.StandardInput)
{
if (writer.BaseStream.CanWrite)
{
// write some commands
}
}
当我调用process.Start()
没有附加内容时,程序会停止他的进度。我不明白为什么,谢谢帮助。
编辑:当我在控制台中按下一个键时,程序继续......