this code works fine on my test system (copy of the original Windows-Server 2008 R2)
private string _getNetFiles()
{
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;
Process process = Process.Start(processStartInfo);
process.WaitForExit();
string stdOutput = process.StandardOutput.ReadToEnd();
string stdError = process.StandardError.ReadToEnd();
return stdOutput;
}
On the source system: I see the cmd.exe / c openfiles / query / Fo list task in Task-Manger, but this task never ends (process.WaitForExit () never ends). Cmd on the source system: openfiles / query / fo list works fine!
Where could the problem be?
- greeting
edit: I can stop the process using the task manager. The value of stdOutput is correct. Why not finish cmd-taks.
source
share