Command prompt output being read as empty string
问题 I'm trying to execute command prompt commands and read the output in C#. This is my code: ProcessStartInfo cmdInfo = new ProcessStartInfo("cmd.exe", "/c " + command); cmdInfo.CreateNoWindow = true; cmdInfo.RedirectStandardOutput = true; cmdInfo.UseShellExecute = false; Process cmd = new Process(); cmd.StartInfo = cmdInfo; cmd.Start(); string result = cmd.StandardOutput.ReadToEnd(); cmd.WaitForExit(); cmd.Close(); return result; It works most of the time, but sometimes result="" when that's