다음 코드가 있습니다.cmd.exe 프로세스가 완료되지 않음
ProcessStartInfo si = new ProcessStartInfo("cmd.exe");
si.RedirectStandardInput = true;
si.RedirectStandardOutput = true;
si.UseShellExecute = false;
si.WindowStyle = ProcessWindowStyle.Hidden;
si.CreateNoWindow = true;
Process p = Process.Start(si);
p.StandardInput.Write("ipconfig");
p.StandardInput.Write("exit");
string consoleOutput = p.StandardOutput.ReadToEnd();
string dir="here";
실행은 "문자열 consoleOutput을"에 도달하지만 결코 코드가 StandardOutput을 읽고 걸리면 즉 "문자열 DIR을"에 도달하지 않습니다. 이것이 차이가 나는 경우 콘솔 응용 프로그램 내에서 실행됩니다.
콘솔 응용 프로그램에서 이미 실행중인 경우'cmdconfig '를 불필요하게 생성하는 대신 자체적으로'ipconfig'를 호출하지 않는 이유는 무엇입니까? – Petesh
console.write로이 작업을 수행 할 수 있습니까? – coolblue2000
console.write는 실제로 프로세스를 시작하지 않으며, 프로세스를 시작하는 것은 'Process.Start (si)'입니다. – Petesh