I want to run a console application (B) from another console application (A). But I want to run the console application (B) from another console window and the original window (from console application A) close.
The standard Process.Start() call should do the job.
Console App A:
public static void Main(string[] args) { Console.WriteLine("This is Console App 'A'..."); string fullPathToB = @"C:\Users\mikes\Documents\Visual Studio 2017\Projects\CS_Console_Scratch2\CS_Console_Scratch2\bin\Debug\ConsoleAppB"; Process.Start(fullPathToB); // this console app will close when we hit the end bracket for Main() }
Console App B:
public static void Main(string[] args) { Console.WriteLine("This is Console App 'B'..."); Console.WriteLine("Press Enter to Quit"); Console.ReadLine(); }
But you'll see different results depending on how Console App "A" was started. If you double click on "A" from File Explorer, then the console window for "A" will close and you'll only see "B".
If you are already at a command prompt and start "A", then that console will stay open and you'll see it and "B" together. Both scenarios are shown below.
Output when "A" is started from File Explorer:

Output when "A" is started from an existing Command Prompt:
