Articles on websites & etc.

§ Home > Index > Linux and FreeBSD

Resolving an unable to fork PHP warning in Windows


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() []: Unable to execute"

Sample Code

// print output of shell command executed with backtick operator
print htmlentities(`dir`);


The most likely cause is insufficient permissions to execute system calls in the web server environment.


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.

  1. Open Windows Explorer and browse to the c:\windows\system32 or c:\winnt\system32 directory.
  2. Right-click on cmd.exe, and select Properties....
  3. Click the Security tab. See image below.

    windows xp file properties security tab iusr read permission.png

  4. If Internet Guest Account is not already listed, then click Add, then Advanced..., then Find Now.
  5. Scroll down to and select IUSR_MachineName, where MachineName is the name of your computer.
  6. Click OK twice to return to the Security tab.
  7. Select Internet Guest Account and then click the box under Allow for Read & Execute.
  8. Click OK.


It is a very bad idea to allow unvalidated input to any system calls. Remember to use escapeshellcmd for any commands that will contain user input.

You will have to give IUSR appropriate permissions to any other files and folders that the PHP script will access.

Read the Program Execution Functions reference materials in the PHP manual for more information.

Applies To

Windows XP, 2000, 2003, PHP, IIS 5.1, fork, system, exec, passthru, shell_exec, backtick operator

Have you heard of the new, free Automated Feeds offered by Google Merchant Center? Learn more in Aten Software's latest blog post comparing them to traditional data feed files.
Created 2006-05-05, Last Modified 2011-07-24, © Shailesh N. Humbad
Disclaimer: This content is provided as-is. The information may be incorrect.