Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Launching process in C# Without Distracting Console Window

Tags:

c#

process

People also ask

What are processes in C?

A process executes a program; you can have multiple processes executing the same program, but each process has its own copy of the program within its own address space and executes it independently of the other copies. Processes are organized hierarchically.

Can a running process spawn another process?

A process can spawn another process dynamically using the posix_spawn() or posix_spawnp() function. This spawned process can be either a supervisor or a user process. Example 3-3 creates a new process.

When we use fork () Where does the child thread begin executing from?

For the child thread fork() will return 0, so the other branch of the if won't be executed, same thing happens for the father thread. Show activity on this post. The child starts by executing the next instruction (not line) after fork.


If I recall correctly, this worked for me

Process process = new Process();

// Stop the process from opening a new window
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;

// Setup executable and parameters
process.StartInfo.FileName = @"c:\test.exe"
process.StartInfo.Arguments = "--test";

// Go
process.Start();

I've been using this from within a C# console application to launch another process, and it stops the application from launching it in a separate window, instead keeping everything in the same window.


@galets In your suggestion, the window is still created, only it begins minimized. This would work better for actually doing what acidzombie24 wanted:

myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

Try this:

myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;

I'll have to double check, but I believe you also need to set UseShellExecute = false. This also lets you capture the standard output/error streams.