I want to call from a c# application a command line starting from it an application and retrieve the stat from it.
I did this but something is missing:
ProcessStartInfo psf = new ProcessStartInfo("cmd.exe", "/C time");
psf.WindowStyle = ProcessWindowStyle.Hidden;
psf.RedirectStandardOutput = true;
psf.UseShellExecute = false;
psf.CreateNoWindow = true;
Process p = Process.Start(psf);
StreamReader sr = p.StandardOutput;
p.WaitForExit();
What is wrong ?
cmd/c Timeexpects user input. It won't close unless you provide some input to it. In your case, you are hiding the command window. That makes it look like an input is pending in hidden window. what do you want the code to do?DateTime.Now?cmd /c time /tas @Lukas has said.