title: WPF C# - get python version by cmd
body: <p>I've try to taken python version, so i've start a process with cmd and a command "python --version".</p>
  
  <p>I've try this for first:</p>
  
  <pre><code>     using (System.Diagnostics.Process p = new System.Diagnostics.Process())
                {
                 p.StartInfo.UseShellExecute = true;
                 p.StartInfo.RedirectStandardOutput = false;
                 p.StartInfo.FileName = "cmd.exe";
                 p.StartInfo.Arguments = "/k C:/Python36/python --version";
                 p.StartInfo.CreateNoWindow = false;
                 var retorno = p.Start();
                }
  </code></pre>
  
  <p>and opened a cmd window and returned this:</p>
  
  <p><a href="https://i.stack.imgur.com/AjYzA.png" rel="nofollow noreferrer">cmd return</a></p>
  
  <p>instead of this, i need this result returned to my WPF application, so i try this:</p>
  
  <pre><code>public static string GetPythonVersion()
      {
        string command = "python --version";
        string output = null;
        using (System.Diagnostics.Process p = new System.Diagnostics.Process())
        {
          p.StartInfo.UseShellExecute = false;
          p.StartInfo.RedirectStandardOutput = true;
          p.StartInfo.FileName = "cmd.exe";
          p.StartInfo.Arguments = String.Format(@"/c {0}\{1} ", "C:/Python36/", command);
          p.StartInfo.CreateNoWindow = true;
          if (p.Start())
            output = p.StandardOutput.ReadToEnd();
        }
       return output;
     }
  </code></pre>
  
  <p>return empty string to me.
  however to an example if i using the same code to return "pip list" to my wpf application working well, but in this case to taken the version the string return empty....</p>