title: Why Process not printing output from cmd C#?
body: <p>I'm tring to get the output from cmd, this command is working fine in the command line:
  <strong>if exist \qwerty (net use T: \querty ) else (echo false)</strong>
  But when I do that from c# doesn't work. Here the methods:</p>
  
  <pre><code>void mapDrive(String driveChar, string server,string user, string password){
  
      try
      {               
          ProcessStartInfo procStartInfo;
          procStartInfo=new ProcessStartInfo();
          procStartInfo.FileName = @"C:\windows\system32\cmd.exe";
          procStartInfo.RedirectStandardOutput = true;
          procStartInfo.RedirectStandardError = true;
          procStartInfo.RedirectStandardInput = true;
          procStartInfo.UseShellExecute = false;
          procStartInfo.CreateNoWindow = true;
  
          Process proc = new Process();
          proc.StartInfo = procStartInfo;
          proc.ErrorDataReceived += cmd_Error;
          proc.OutputDataReceived += cmd_DataReceived;
          proc.EnableRaisingEvents = true;
          proc.Start();
          proc.BeginOutputReadLine();
          proc.BeginErrorReadLine();
  
          proc.StandardInput.WriteLine(" if exist "+server+"(net use "+driveChar+": "+server+" /user:"+user+" "+password+" ) else (echo false)");
          //it should print 'false'
          proc.WaitForExit();     
  
      }
      catch (Exception e)
      {
          // MessageBox.Show(e.Message);
      }
  }
  
  static void cmd_DataReceived(object sender, DataReceivedEventArgs e)
  {
      Console.WriteLine("Output from other process");
      Console.WriteLine(e.Data);
  }
  
  static void cmd_Error(object sender, DataReceivedEventArgs e)
  {
      Console.WriteLine("Error from other process");
      Console.WriteLine(e.Data);
  }
  </code></pre>
  
  <p>I took the code from <a href="https://stackoverflow.com/questions/5367557/how-to-parse-command-line-output-from-c">here</a></p>
  
  <p>EDIT:
  Replaced 'Debug' FOR 'Console'.</p>