php manual中有
"Unable to fork..." errors when executing "shell_exec" or "system" functions.After numerous hours of testing, I realized that this error is a result of insufficient file permissions.  You will need to locate c:\Windows\system32\cmd.exe and set the permission to at least Read & Executable for Internet Guest user accounts.
主要讲:
1  locate c:\Windows\system32\cmd.exe 
2  set the permission for Guest user accounts
试一试:
exec( 'c:\\Windows\\system32\\cmd.exe echo '.$num." > ".$counterFile);