Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have created a C# Project which has multiple console applications in it. Now my question is; Is it possible to display multiple consoles when I run one application? if yes, how?

Lets say, I have a Test Application, which is the main console application. I have another two Console applications, say, ABC and XYZ. Now, when i run the Test Application, the console of both applications ABC and XYZ should appear.

I have used the following code: -

C#
Console.WriteLine("\n\t Calling EXE...");
Process myProcess = new Process();
string Exepath = System.IO.Directory.GetCurrentDirectory() + "\\exe\\ABCApplication.exe";
try
{
    myProcess.StartInfo.UseShellExecute = false;
    myProcess.StartInfo.FileName = Exepath;
    myProcess.StartInfo.CreateNoWindow = false;
    myProcess.Start();
}

catch (Exception ex)
{
    CreateLogFile();
}




Thank you.
Posted
Updated 8-Jun-15 21:17pm
v2

From your starting console app , pass the path to process method of other console apps (ABC and xyz)
Process.Start("C:\\ABC ");

add namespace:
using System.Diagnostics;
 
Share this answer
 
v2
Comments
Member 11185261 9-Jun-15 3:21am    
@sasanka sekhar panda
Kindly check the question, I have mentioned the code which I have used.
I believe that the only way to start detached console applications from a host console application is to set UseShellExecute to true. This is the default setting so @sasanka sekhar panda's answer was correct but he didn't explain why.

If you really need UseShellExecute == false then, as far as I can tell, it's not possible to suppress console sharing. An alternative would be to make the host a GUI app which would give you freedom to set UseShellExecute however you wish.

Alan.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900