Windows Server 2003 x64

PHP 5.2

IIS 6.0

The program Ink2Png.exe is set with Everyone->Read and Execute permissions.

As does its dependency (microsoft.ink.dll)

PHP Safe Mode is off

exec() is passed [the full exe path], space, [full path to another file]

This other file also has full read permissions.

The output directory has full write permissions.

As soon as exec() is hit, the connection dies, the browser does not even receive a full set of http headers, and it reports a CGI error. Examining the output, it appears the program was not even run.

Any ideas? How can I figure out what exactly is happening and get it running again?

EDIT: Also, it is a .NET application, if that is significant in any way.

4 Answers 4


@Patrick: If you've only given the user Everyone access, then you'll need to add read/execute permissions for IUSR_<MachineName> and IWAM_<MachineName> as well and IIS_WPG too if you're still having issues. Remember to give Write access for all those users for your output directory as well.

  • Well the IUSR was already there, and the only IWAM_ ones were _plesk(default) and _TEMPLATE, so I added them and the WPG just for good measure. No dice.
    – Patrick
    Commented Mar 22, 2011 at 23:47

What status code is stored in the IIS logs for such an attempt?

Could it be the Web Service Extension list preventing execution? (would have thought it unlikely, would have only expected a single level of executable blocking, but there ya go)

  • This is the log line: 2011-05-30 17:14:44 W3SVC11083 CT3462 GET /mobile/beta/patients/view.php id=4 80 - HTTP/1.1 Mozilla/5.0+(Windows+NT+6.0;+WOW64)+AppleWebKit/534.24+(KHTML,+like+Gecko)+Chrome/11.0.696.68+Safari/534.24 mem_user=<redacted>;+mem_pass=<redacted>;+PHPSESSID=<redacted> http://<domain>/mobile/beta/patients/list.php <domain> 502 2 2147500037 417 645 1500
    – Patrick
    Commented May 30, 2011 at 17:24
  • 502 is a Bad Gateway error, not sure what the substatus code 2 is, and the win32 error code translates to 0x80004005 -> access denied. If this si still in beta, I'd suggest a) firewalling the box so nothing else can get to it, b) turning off the ISAPI and CGI restrictions just to doublecheck it's not preventing them from running. Also, if you're using PHP, how is it a .Net application? What's the relationship there? Could it be .Net CAS policy preventing you from running arbitrary EXEs? Think you may need to talk to Microsoft support to nut this one out, loads more detail needed.
    – TristanK
    Commented May 31, 2011 at 1:57
  • The exe that PHP uses exec on is the .NET application. Pass it a .isf and it spits out a .png. The active version relies on a quick-and-dirty windows service that monitors the folder for any new .isf files and converts them automatically, but that still leaves the chance that it could miss one before the request for the .png comes in. The PHP user has full access to execute that file, I even went as far as letting everyone run it, and still nothing.
    – Patrick
    Commented May 31, 2011 at 12:36
  • Also, the exe is signed and works under cmd without PHP. So it's access denied to something, but it's not telling me what or where or why.
    – Patrick
    Commented May 31, 2011 at 13:11

To execute a .exe file with PHP, you'll need execute permissions on cmd.exe for the IUSR_account. Obviously this is a very bad idea.


To not have to give permission on cmd.exe, would it be better to simply copy your .exe to the cgi-bin directory (rename it as a .cgi in example) and call it as a cgi from there ? (a small exemple; http://www.brinkster.com/KB/Article~KBA-01127-J2K8K3~PHP-call-out-to-cgi-script-example)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .