[英]difference between the following
In order to prevent another command windows from showing, I have tried the following two methods 为了防止显示另一个命令窗口,我尝试了以下两种方法
1) 1)
StartInfo.UseShellExecute = true;
StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
2) 2)
StartInfo.UseShellExecute = false;
Is there any pros and cons of those usage? 这些用法有什么利弊吗?
There are many advantages of setting StartInfo.UseShellExecute to false. 将StartInfo.UseShellExecute设置为false有很多优点。
One of which is if you can redirect standard input,standard output and standard error and read those streams. 其中之一就是您是否可以重定向标准输入,标准输出和标准错误并读取这些流。 This is very useful when something goes wrong.
当出现问题时,这非常有用。 By reading standard error stream you can determine whether any error had occured or not.
通过阅读标准错误流,您可以确定是否发生了任何错误。
For more information on shellExecute follow this link 有关shellExecute的更多信息,请单击此链接
About StartInfo.WindowStyle property, if we keep it to false command prompt pops up when process starts. 关于StartInfo.WindowStyle属性,如果我们将其设置为false,则在进程启动时会弹出命令提示符。 If your application has nice,rich UI and then suddenly one black window pops up, it will annoy users plus some users might try to close command prompt before process exits.. and there are many more reasons for keeping window hidden.
如果您的应用程序具有漂亮的,丰富的UI,然后突然弹出一个黑色窗口,它将使用户烦恼,并且一些用户可能会在进程退出之前尝试关闭命令提示符。.还有许多原因使窗口保持隐藏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.