Starting a process in C # without a distracting console window

I will figure out how to start the process. But now the problem is that the console window (in this case 7z) pops up, blocking my vision and removing my focus, interrupting my sentence, or w / e, I do it every few seconds. It is very annoying how I can prevent this. I thought CreateNoWindow solves this, but it is not.

NOTE. Sometimes the console requires user input (replace the file or not). So completely hiding this can be a problem.

This is my current code.

void doSomething(...) { myProcess.StartInfo.FileName = ...; myProcess.StartInfo.Arguments = ...; myProcess.StartInfo.CreateNoWindow = true; myProcess.Start(); myProcess.WaitForExit(); } 
+54
c # process
Apr 10 '09 at 10:50
source share
4 answers

If I remember correctly, it 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 used this from a C # console application to start another process, and it stops the application from starting in a separate window, instead saving everything in one window.

+85
Apr 10 '09 at 23:17
source share

@galets At your suggestion, the window is still created, only it is starting to be minimized. This would be better for actually doing what acidzombie24 wanted:

 myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; 
+20
Jul 08 '10 at 22:30
source share

Try the following:

 myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized; 
+3
Apr 10 '09 at 22:54
source share

I will have to double check, but I believe that you also need to set UseShellExecute = false . It also allows capturing standard output / error streams.

+3
Apr 10 '09 at 23:06
source share



All Articles