Process 클래스를 사용하여 tasklist.exe를 실행하고 RedirectStandardOutput을 true로 설정하려고하면 프로세스가 종료되지 않습니다.표준 출력을 리디렉션 할 때 TaskList.exe가 끝나지 않는 이유는 무엇입니까?
using System.Diagnostics;
class Program
{
static void Main(string[] args)
{
RunProcess("tasklist.exe");
}
private static void RunProcess(string command)
{
var process = new Process()
{
StartInfo =
{
FileName = command,
RedirectStandardOutput = true,
UseShellExecute = false
}
};
process.Start();
process.WaitForExit();
}
}
RedirectStandardOutput을 false로 설정하면 프로세스가 종료됩니다 !!!
tasklist.exe 프로세스가 절대로 종료되지 않는 이유는 무엇입니까? Windows 7과 .NET Framework 4.5.2를 사용하고 있습니다.
나는 tasklist.exe를 강제 종료 할 때마다 정확히 4096 바이트가 표준 출력에 기록된다는 것을 알았습니다! 크기를 늘려야하는 문자 버퍼가 있습니까?
당신은 출력을 읽지 않는를 .. – Blorgbeard
왜 그 문제를합니까? – LVBen
WaitForExit 다음에이 두 줄을 쉽게 추가 할 수 있지만 실행되지 않습니다. var response = process.StandardOutput.ReadToEnd(); Console.WriteLine (response); – LVBen