If I understand you right, this is quite possible, and I myself have been trying to do it. You want to basically pass a variable from C# into a console app, and automatically run it, then return the value into C#?
First import
System.Diagnostics and
System.IO into C#, then:
Code:
string call = @"""(the path to your console app)""";
string param1 = @"""(console param1)""";
string param2 = "(console param2)";
Process theProcess = new Process();
string args = string.Format("{0} {1}", param1, param2);
ProcessStartInfo theProcessStartInfo = new ProcessStartInfo(call, "spawn");
theProcessStartInfo.UseShellExecute = false;
theProcessStartInfo.RedirectStandardOutput = true;
theProcessStartInfo.Arguments = args;
theProcess.StartInfo = theProcessStartInfo;
theProcess.Start();
StreamReader theStreamReader = theProcess.StandardOutput;
while (theStreamReader.ReadLine() != null) {
string name = theStreamReader.ReadLine();
MessageBox.Show(name);
}
This will call the console app and automatically run it with param1 and param2. In other words, it would be the same as doing this in the command prompt:
"(the path to your console app)" "(console param1)" (console param2)
and pressing enter. If you need quotes inside the actual command, in C# you need to use
@"""(param)""" so that the double quotes will make it to the console.
Is this what you are looking for? I am still having some trouble getting this to completely work...let me know if this is what you're trying to do, as well.