How to get value from cosole application calling via cmd.exe

  • Thread starter Thread starter Sathiya Jeba
  • Start date Start date
S

Sathiya Jeba

Guest
I have a console which will be calling on cmd.exe.

I am using process.start to call the cmd.exe and passing the console exe as a parameter to process.

my console exe should return some values.

How to get the return value from the console exe.

Herewith I have attached the code i tried for more clarity.

string cPath = @"C:\v2";
string filename = Path.Combine(cPath, "myapps.exe");
string cParams = string.Empty;
//Param
cParams = filename + " param1 " + "param1" + " " + "param3";

ProcessStartInfo ProcessInfo;
Process Process;
ProcessInfo = new ProcessStartInfo("cmd.exe", "/K " + Command);

ProcessInfo.UseShellExecute = false;
ProcessInfo.CreateNoWindow = false;
Process = Process.Start(ProcessInfo);

From the above example, myapps.exe should return some values such as 0 or -1 or 1 or 2. I would like to get the return value from the process. How to achieve this?

Thanks in Advance,

Sathiya Jeba C

Continue reading...
 
Back
Top