Symptoms
In Windows, when trying to execute a system call from a PHP script, you receive a warning like "Warning: system() [function.system]: Unable to fork". A related warning message is "Warning: shell_exec() [function.shell-exec]: Unable to execute"
Sample Code
<?php
// print output of shell command executed with backtick operator
print htmlentities(`dir`);
?>
Cause
The most likely cause is insufficient permissions to execute system calls in the web server environment.
Fix
You need to give the Internet Guest Account (a.k.a. IUSR_MachineName or simply IUSR) read and execute permission to the command shell program, cmd.exe
. Typically, permission to this file is explicitly denied as a security measure.
- Open Windows Explorer and browse to the
c:/windows/system32
orc:/winnt/system32
directory. - Right-click on
cmd.exe
, and select Properties.... - Click the Security tab. See image below.
-
- If Internet Guest Account is not already listed, then click Add, then Advanced..., then Find Now.
- Scroll down to and select IUSR_MachineName, where MachineName is the name of your computer.
- Click OK twice to return to the Security tab.
- Select Internet Guest Account and then click the box under Allow for Read & Execute.
- Click OK.