this code works fine on my test-system (Copy of the original Windows-Server 2008 R2)
private string _getNetFiles()
{
// prepare execution process
ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe", "/c openfiles /query /Fo list");
processStartInfo.CreateNoWindow = true;
processStartInfo.UseShellExecute = false;
processStartInfo.RedirectStandardError = true;
processStartInfo.StandardOutputEncoding = System.Text.Encoding.GetEncoding(437);
processStartInfo.RedirectStandardOutput = true;
// execute
Process process = Process.Start(processStartInfo);
process.WaitForExit();
// read outputs
string stdOutput = process.StandardOutput.ReadToEnd();
string stdError = process.StandardError.ReadToEnd();
return stdOutput;
}
On the original system: I see the "cmd.exe /c openfiles /query /Fo list" task in the Task-Manger, but this task never end (process.WaitForExit() process never end ). Cmd on the original system: openfiles /query /fo list works also fine!
Where can the problem be?
regards raiserle
edit: I can stop the process with task-manager. The stdOutput is correct. Why don't end the cmd-taks.