Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get shell_exec to run on IIS 6.0
    primarykey
    data
    text
    <p><strong>The Problem</strong></p> <p>I have a PHP script that uses <code>shell_exec</code> to run a pdf-to-text converter. To simplify the problem I've created a short script that uses <code>shell_exec</code> to just echo the output of the <code>dir</code> command.</p> <pre><code>&lt;?php $cmd = 'C:\\WINDOWS\\system32\\cmd.exe /c '; echo shell_exec($cmd.' dir'); ?&gt; </code></pre> <p>When I run this on my Apache server, everything works as expected. When I switch to IIS, it's as though the line is skipped entirely: no errors, no output, no logs, no nothing.</p> <p>Unfortunately, I need to use IIS because I'm going to authenticate my users against active directory.</p> <hr> <p><strong>Here's what I've tried so far:</strong></p> <ul> <li>Issue the command through <code>cmd.exe /c</code> rather than issuing it directly</li> <li>Give <code>Read &amp; Execute</code> permission to <code>SERVICE</code> on "C:\WINDOWS\system32\cmd.exe"</li> <li>Give <code>Read &amp; Execute</code> permission to <code>NETWORK SERVICE</code> on "C:\WINDOWS\system32\cmd.exe"</li> <li>Give <code>Read &amp; Execute</code> permission to <code>IUSR_MACHINENAME</code> on "C:\WINDOWS\system32\cmd.exe"</li> <li>Give <code>Read &amp; Execute</code> permission to <code>Everyone</code> on "C:\WINDOWS\system32\cmd.exe" (don't worry, it didn't stay like that for long, haha)</li> <li>Run PHP as an ASAPI module <ul> <li>This is my standard configuration</li> </ul></li> <li>Run PHP as a CGI extention <ul> <li>This does not work, I get an error: <code>CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers.</code></li> </ul></li> <li>In IIS Manager, set <code>Execute Permissions</code> to <code>Scripts and Executables</code> on your website</li> <li>Added html markup and other php functions to script to see if that gets processed; it does. It's as if the <code>shell_exec</code> bit just gets skipped.</li> </ul> <hr> <p>Thank you so much for looking at this question, I am now pulling my hair out with the problem</p> <p>Cheers, Iain</p> <hr> <p><strong>Update 1</strong></p> <p>I really didn't want to do this, but as a stop gap until I find a proper solution I'm running Apache on the web server (which runs shell_exec fine) and I call my apache script via cURL. It's ugly, but it works :).</p> <hr> <p><strong>Update 2</strong></p> <p>I'm beginning to think this isn't so much an issue with IIS or permissions as such, but perhaps a result of some policy we have on our network - although I can't imagine what. Any ideas from left of field?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload