Zikko's Resources


Unable to Fork - Running PHP exec/system on IIS

It's been discussed a thousand times I guess, usually in too much detail, so I'll keep it short here. PHP has a couple of ways to execute code as if it was done from a DOS window, such as exec, system and passthru. These commands have little differences, see the PHP docs for details. However, they are all known to fail mysteriously when run on IIS servers.

But why?

This has to do with the permission settings of a little program called cmd.exe or something like that. And it's just the little "something like that" that is the confusing bit. The name and the path of it is different in different environments and operative systems, and so is the system name of your computer which is also needed to put things right. So - here's a little code snippet that retrieves those things from the environment so you don't have to worry about it, and sets the neccessary permissions. You need to run it from commandline, and only once.

The shit

cacls %COMSPEC% /E /G %COMPUTERNAME%\IUSR_%COMPUTERNAME%:R


All content on these pages may be used, copied and modifed freely. Questions or comments may be sent to . Also visit zikko.se.