title: How do I run a command line tool from a different directory in C++
body: <p>I am trying to build a C++ application that makes a bunch of command line calls on the Windows command prompt using the <code>system()</code> function. The C++ runs in directory <em>BSP</em> below. <em>BSP</em> contains a sub-folder <em>BSP/XST/Files</em>. One of the commands the application makes, needs to call a command line tool (Xilinx Synthesis tools) that needs to run in the <em>Files</em> directory.</p>
  
  <pre><code>BSP
  |---XST
  |---|---Files
  </code></pre>
  
  <p>Doing it manually on the command prompt I would do something similar to:</p>
  
  <pre><code>&gt;&gt;cd XST
  &gt;&gt;cd Files
  &gt;&gt;xst -h
  </code></pre>
  
  <p>Is there a way to call a tool in the sub-directory from the <em>BSP</em> directory?
  I looked at this question <a href="https://stackoverflow.com/questions/3903288/run-an-exe-from-a-different-directory">here</a>, but it does not work. I'm guessing because they are talking about an executable that is stored within the sub-directory whereas I am calling a command line tool (i.e. uses environment variables).</p>
  
  <p>To simplify: Is there a command/option to run a command line tool in a sub-folder on the Windows command prompt? I can just emulate the statement via my C++.</p>