简体   繁体   中英

Running program in background from command line

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");

Add that line :

 proc.StartInfo.Arguments = " /c;

And that one :

proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

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. 在此处输入图片说明

Here 'sa 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM