views:

21

answers:

1

Hi, I have a console application written in c# which starts a new process. This new process is also a console application. The problem is that whole child process output goes to parent console window and i don't want it to. It doesn't matter if it creates a new console window or not, I don't need it.

Edit:

Process p = new Process(); 
p.StartInfo.FileName = @"C:\example.exe";
p.Start();

I tried some additional setting like CreateNoWindow, RedirectOutput and so on but with no luck

A: 

Normally, when you create a child process, a new console window pops up and all output of the child process ends up in that window. Here is a sample program that exhibits this behavior:

using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;

static class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine("TEST");

        if (args.Length == 0)
        {
            string path = Assembly.GetExecutingAssembly().Location;
            Process.Start(path, "DontStartProcess");
        }
        Console.ReadLine();
    }
}
0xA3