title: run PHP exec command on Windows IIS7
body: <p>Had issues with running exec() and shell_exec() from php code.
  I'm running PHP5.3 on Windows IIS7.
  (spent several hours on this and got it finally...)</p>
  
  <p>The following exec() code works:</p>
  
  <pre><code>$cmd='cmd.exe /c C:\\&lt;path/to/php/directory/&gt;\php.exe -v';
  exec($cmd,$output,$err);
  var_dump($output); //dump the output
  echo $err; //show the error code, should give 0 for no errors
  </code></pre>
  
  <p>Note i have ensure that:
  - The IIS Internet User has the full read+execute rights to the PHP directory
  - The IIS Internet User has the full read+execute rights to php.exe
  - The IIS Internet User has the full read+execute rights to cmd.exe</p>
  
  <p>If you are outputting alot of data from your background process php file, use shell_exec(), see working code below (at least on my setup):</p>
  
  <pre><code>$cmd='cmd.exe /c C:\\&lt;path/to/php/directory/&gt;\php.exe -f C:\\&lt;path\to\your\&gt;\cron.php';
  echo shell_exec($cmd); //output the data
  </code></pre>
  
  <p>Note if it returns nothing, means there is something wrong with the path.</p>
  
  <p>Remember to use " \ " (without quotes) to emulate/substitute single backslash " \ " in actual windows paths.</p>
  
  <p>Make sure your background process file i.e. cron.php has permissions for IIS Internet User as well. Have fun!</p>