Execute dos command using c#.net
Hi, im using c#.net 2005 to develop an application. in my app i have to execute an .exe file with some argument. let say the file name is abc.exe and arguments are 'argStr'. it normaly executes in dosprompt. i used the following code.
System.Diagnostics.Process.Start("abc", argStr);
it executes the command . but it shows the command prompt (cmd.exe) on the application. is there any way to not display the command prompt and read the output of the execution of the execution which is displayed in the dos prompts?
Thank you.
Anushka
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

naura paxRank #2,843 · 502 reputationPosted Jul 7, 2009, 8:48 PM EDT
Try this and read the result. Please tell me if it was worth it.
string argString = "whatever";
System.Diagnostics.Process p= new System.Diagnostics.Process();
p.StartInfo.Arguments = argString;
p.StartInfo.FileName = @"c:\d-data\WorkFolder\ProjectEuler\NewCheck.exe";//your file path goes here.
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();
string result = p.StandardOutput.ReadToEnd();
if (p.HasExited)
p.Dispose();