0

Is it possible to run another console application in running console. Lets say I got program that write hello world, i got her as exe file. Now I am running another program, can i run the other one in the second one? i want to run the hello world in the second program, its like running a process but in this console. I want to run the code and then continue the program that called it.

Is it possible some how?

I didn't find the answer anywhere... My idea is to write scripts and shell for them which will run them. If you got another idea i would like to hear it to. I want it in C# so cygwin or any other shell (which is not c#) won't help me.

4

2 回答 2

1

You should use System.Diagnostics.Proces class to run the secondary process More details here

于 2013-09-15T12:27:35.517 回答
0

同一个控制台是什么意思?你想运行一个程序并得到结果,如果你不希望它在后台运行,使用:

Process p = Process.Start("exe fullname");
p.WaitForExit();
if (p.ExitCode == 0)
{
    //everything is good
}
else
{
    //the program wasn't successful
}

但是,如果您希望它在后台运行,那么您需要使用 Task
这是一篇关于任务的完整文章

注意:如果它是另一个控制台应用程序,并且您想使用结果,则使用ProcessStartInfo

于 2014-02-08T16:03:03.240 回答