title: Writeline to already running process
body: <p>Here is my code:</p>
  
  <pre><code>static void Main(string[] args)
  {
      if(args.Length &gt; 1)
      {
          int id;
          if(int.TryParse(args[0], out id))
          {
              try
              {
                  var p = Process.GetProcessById(id);
                  p.StandardInput.WriteLine(args[1]);
              }
              catch (ArgumentException)
              {
                  Console.WriteLine($"Couldn't find process with id {id}");
              }
          }
          else
          {
              Console.WriteLine($"Couldn't find process with id {args[0]}");
          }
      }
  }
  </code></pre>
  
  <p>I got a process by its id.  That worked fine
  Then I tried to send something to its stdin.  That threw an InvalidOperationException.  Note: the exception occured when I tried to get the StandardInput, not when I tried to us WriteLine.</p>
  
  <p>I believe I know why I got the exception. The process was not started by my application, so I never had the chance to set RedirectStandardInput to true.</p>
  
  <p>My goal is to be able to use this app to send text to a python interactive console(or another language).  I still want to be able to enter text myself to the python prompt, but I also want to give my app control too.</p>
  
  <p>How do I do this?</p>