title: Visual Studio x86 tools, normal cmd.exe, Process.Start()
body: <p>I need to write some code to invoke <a href="https://code.google.com/p/tesseract-ocr/" rel="nofollow">tesseract OCR</a> in C#. I installed it and use the follow code. But it doesn't work:</p>
  
  <pre><code>  ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.FileName = "cmd.exe";
    startInfo.WorkingDirectory = tempDir.FullName;
  
    // doesn't work
    startInfo.Arguments = string.Format("/C tesseract {0} {1}", imgName, textName);
    // this works
    //startInfo.Arguments = string.Format("/C copy {0} {1}", imgName, textName);
  
    Process p = new Process();
    p.StartInfo = startInfo;
    p.Start();
    p.WaitForExit();
    p.Close();
  </code></pre>
  
  <p>No exception or error is thrown. I just can't get the output file in the directory. I try a built-in command like the <code>copy</code> which commented and it works. I tried to get the stdout of the process but it always throw a "Process exit" exception.</p>
  
  <p>After that I try to call tesseract in a command window. I cd into the temp dir, run <code>tesseract img.png output</code> and here the interest thing happens: </p>
  
  <ol>
  <li>When start the command window via Start->Run->cmd, it works fine.</li>
  <li>When start the command window in Visual Studio solution explorer, right click-> Open Command Prompt (It's a feature of <a href="http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef" rel="nofollow">VS Productivity Power Tools</a>), it shows "tesseract is not recognized as an internal or external command".</li>
  </ol>
  
  <p>I check the PATH in environment variable, it is correct. The only difference I can see is that the VS prompt shows "Setting environment for using Microsoft Visual Studio 2010 x86 tools." on the top. Doesn't it search the PATH variable to find command? Aren't they the same thing? Is it somehow related to my C# code's failure?</p>
  
  <p>My OS is Windows Server 2008 64-bit.</p>