我的wpf应用程序调用python脚本来生成稍后显示在UI中的输出。为避免应用程序崩溃,如果未在用户系统上安装python,我需要执行检查。目前,我已经实现了使用以下WPF检查系统上是否安装了python
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = @"cmd.exe"; // Specify exe name.
start.Arguments = "python --version";
start.UseShellExecute = false;
start.RedirectStandardError = true;
using (Process process = Process.Start(start))
{
using (StreamReader reader = process.StandardError)
{
string result = reader.ReadToEnd();
MessageBox.Show(result);
}
}
这做工作,但促使CMD黑色窗口这是非常不希望的瞬间外观。是否有解决方法来实现此目的或修复以避免出现窗口?
也许add start.CreateNoWindow = true; ? – Dave3of5
可能的复制:http://stackoverflow.com/questions/5377423/hide-console-window-from-process-start-c-sharp – clcto