title: How to run a command without opening new shell using the AutoIt command line
body: <p>I am currently writing a command line application in AutoIt and am having trouble with making it print back to the same command line I opened it in. My goal is to have the entire program work within a single shell. Here is what I tried initially:</p>
  
  <pre><code>;myprogram.au3
  $MyCommand = 'dir'
  Run(@ComSpec &amp; " /c " &amp; $MyCommand, @SystemDir, @SW_Show)
  Run(@ComSpec &amp; " /c @echo off &amp;&amp; echo Command completed successfully. &amp;&amp; @echo on", @SystemDir, @SW_Show)
  </code></pre>
  
  <p>Then I compiled it and ran it via the command line (each code box represents a new shell):</p>
  
  <pre><code>C:\Users\Matthew&gt;myprogram.au3
  C:\Users\Matthew&gt;
  </code></pre>
  
  <p>Opens new shell
     ↓</p>
  
  <pre><code>Volume in drive C has no label.
  Volume Serial Number is 0287-990C
  Directory of C:\Users\Matthew
  &lt;Finishes normal dir command output&gt;
  </code></pre>
  
  <p>Once finished, listing files in my directory that exits and</p>
  
  <p>Opens new shell
     ↓</p>
  
  <pre><code>The command completed successfully.
  </code></pre>
  
  <p>And that window closes immediately.</p>
  
  <p>The output I am looking for is the same thing, but in one window, like this:</p>
  
  <pre><code>C:\Users\Matthew&gt;myprogram
  *Output of dir command*
  The command completed successfully
  C:\Users\Matthew&gt;
  </code></pre>