[英]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: 是否可以:
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.
将输出类型更改为Windows应用程序。
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. 这是一个解决方案,可让您在需要时仍然显示控制台,例如,如果出现问题并且想要警告用户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.