title: Open3.popen3 returns wrong error Errno::ENOENT on Windows
body: <p>I have the following code in test.rb:</p>
  
  <pre><code>require 'open3'
  cmd = 'C:\Program Files\foo\bar.exe'
  Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
    puts "stdout: #{stdout.read}"
    puts "\n\n"
    puts "stderr: #{stderr.read}"
  end
  </code></pre>
  
  <p><code>bar.exe</code> is a console application that I created, located in <code>C:\Program Files\foo\</code>. When I run <code>bar.exe</code>:</p>
  
  <ul>
  <li>it outputs <code>"Hello world!"</code></li>
  <li>with any argument, like <code>bar.exe /blah</code>, it outputs a help message.</li>
  </ul>
  
  <p>When I run <code>ruby test.rb</code> I get this error:</p>
  
  <pre><code>C:\RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/open3.rb:193:in 'spawn': No such file or directory - C:\Program Files\foo\bar.exe (Errno::ENOENT)
  from C:\RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/open3.rb:193:in 'popen_run'
  from C:\RailsInstaller/Ruby2.2.0/lib/ruby/2.2.0/open3.rb:193:in 'popen3'
  from test.rb:3:in '&lt;main&gt;'
  </code></pre>
  
  <p>If I change the code to call <code>popen3</code>:</p>
  
  <pre><code>Open3.popen3(cmd, '')
  </code></pre>
  
  <p>I don't get the <code>Errno::ENOENT</code> error, instead I get the help message, but I want the <code>"Hello World"</code> output.</p>
  
  <p>I searched for a solution but nothing is working, including the answer to "<a href="https://stackoverflow.com/questions/26040249/why-does-open3-popen3-return-wrong-error-when-executable-is-missing/26040994#26040994">Why does Open3.popen3 return wrong error when executable is missing?</a>".</p>
  
  <p>Why am I getting this error and how do I solve it?</p>