There are a few work arounds I’ve found since having to use PHP under IIS6 and Windows 2003. Every now and again I come across something that just doesn’t work the same way with this variation of web server, OS and PHP.
I needed to double-check the DNS hostname being reported from users on an internal website. Our DNS is a little scratchy when it comes to scavenging and keeping itself tidy, so often a DNS lookup of the client IP will give an incorrect name. This happens especially for laptops that hop off and on wireless APs.
So to compare against DNS (and because it’s an internal site) I thought to query the machines NetBIOS name with,
exec("nbtstat.exe -A 188.8.131.52",$r);
and that quickly fails with an error about “failing to fork”. Essentially this means, PHP can’t do what you want.
It boils down to file permissions. you need to run cmd.exe and nbtstat.exe with that single command. Both those files are secured against non-system users – probably rightly so too.
To resolve, just allow your IUSR_SERVER user to have read and execute permissions on both those files. Your exec() command should now be working.
REMEMBER: You are responsible for the security of your server. If you really don’t need to let programs run on your web server, then don’t.