我的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