title: How to read and write to console window continuously and logging all the console data to a text file
body: <p>I have a console application which I need to run like <code>c:\abc.exe -showhidden</code>.</p>
  
  <p>Once executed, it asks the user to select option A (for example number 32|64) and after the user selection it shows some more options (from 1 to 100) on the console, say option B and on the basis of option B selection, it performs some operations on the console continuously.</p>
  
  <p>I tried using the below code for providing the input:</p>
  
  <pre class="lang-vb prettyprint-override"><code>    Dim StartInfo As New System.Diagnostics.ProcessStartInfo
      StartInfo.FileName = "C:\abc.exe"
      StartInfo.Arguments = " -showhidden"
      StartInfo.RedirectStandardInput = True
      StartInfo.RedirectStandardOutput = True
      StartInfo.UseShellExecute = False
       CMDprocess.StartInfo = StartInfo
       CMDprocess.Start()
       CMDProcess.StandardInput.AutoFlush = True  
          Dim sw As System.IO.StreamWriter = CMDprocess.StandardInput
              sw.Writeline("32") ' option A
              sw.WriteLine("86") ' option B
              CMDProcess.StandardInput.Flush()
  </code></pre>
  
  <p>Issues I have:</p>
  
  <ol>
  <li><p>The console hangs after <code>sw.Writeline("32")</code> and I am unable to provide option B, i.e., <code>sw.WriteLine("86")</code>.</p></li>
  <li><p>How to log the output (after selecting option B) to a text file.</p></li>
  </ol>