Using PHP exec() with IIS6
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 123.123.123.123",$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.
Blog Categories
Recent Stuff
Twitter Updates
- Working on 3G this morning via tethered ICS. Thank goodness for VPN and RDP among other acronyms
- RT @rmi: Competition is something that happens to people who can't afford to buy government. It doesn't affect telcos.
- We're new in the "Glen" but just found the local chippy is great. And downpour waited until we were driving home from picnic dinner. Nice
- @daihenwood I've got an older Nexus S with ICS. iPhone seems criplled now. Recommend a Google native experience cmpd to Galaxy S2,etc
- RT @AnonyOps: #Germany protests, #Greece burns, #Syria bleeds. #America watches the #Grammys.


