0

So I have a console application that runs a command line process and then closes. For that second that the process gets called, I can see the window of the process pop up then disappear.

Is it possible to either:

  • Run the other process in the background
  • Run the other process minimized so that it still shows on the taskbar but not on the screen.

My code currently:

var proc = new Process();
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardInput = true;
proc.Start();

proc.StandardInput.WriteLine(@"Navigate to Correct Folder");
proc.StandardInput.WriteLine(@"Run Outside Program");
Mr.Smithyyy
  • 2,157
  • 12
  • 49
  • 95

2 Answers2

0

Add that line :

 proc.StartInfo.Arguments = " /c;

And that one :

proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
0

I suspect that you're actually seeing the window of your console application, and not the process you're launching. Change the output type to Windows Application.enter image description here

Here's a solution that will allow you to show the console still if you need to, for example, if something goes wrong and you want to alert the user.

Community
  • 1
  • 1
DrewJordan
  • 5,266
  • 1
  • 25
  • 39