calling command line from .NET application

Posted by Roman Dorevich on Stack Overflow See other posts from Stack Overflow or by Roman Dorevich
Published on 2010-02-21T08:52:50Z Indexed on 2010/05/09 22:38 UTC
Read the original article Hit count: 167

Filed under:
|
|

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 ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about command-line