title: PHP exec() and system() functions always return false in IIS
body: <p>I'm trying to use the PHP exec() or system() (or any other similar function) to run a batch file, but I can't seem to get these to return anything.</p>
  
  <p>The simplest example I've seen is this, which outputs nothing:</p>
  
  <pre><code>&lt;?php
      echo system('dir');
  ?&gt;
  </code></pre>
  
  <p>The script is running on a windows XP machine on IIS with PHP installed and I've also tried it on my shared hosting account running windows 2003 server/IIS.</p>
  
  <p>Can anyone suggest what I need to do to get this working, or provide any commands I can use for troubleshooting?</p>
  
  <p>Cheers,</p>
  
  <p>Tom</p>
  
  <p><strong>Edit: second example</strong></p>
  
  <p>Based on pavun_cool's answer I tried the following:</p>
  
  <pre><code>&lt;?php
      $last_line = system('dir', $retval);
      echo 'last_line '.$last_line.'&lt;br/&gt; retval '.$retval;
  ?&gt;
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>last_line
  retval -1
  </code></pre>
  
  <p><strong>Edit: third example</strong></p>
  
  <p>Based on Manos Dilaverakis I tried the following code</p>
  
  <pre><code>&lt;?php
  exec('dir', $response);
  foreach($response as $line) {
      echo $line . "&lt;br&gt;";
  }
  ?&gt;
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>&lt;br&gt;
  </code></pre>
  
  <p>I.e. a blank line when displayed in a browser.</p>
  
  <p>Also looking in <code>php.ini</code>, the following line (which presumably could disable these functions) is empty:</p>
  
  <pre><code>disable_functions =
  </code></pre>
  
  <p>Does anyone have any further suggestions or anything else I can try?</p>