So, I found out through much trial and tribulation that (at least in server 2008 r2 w/IIS7 ) executing the shutdown command from fast_cgi or php is not possible. I only had to install apache and execute the shutdown command under it, and the command worked perfectly.
php exec shutdown command not working on IIS 7
-
31-08-2022 - |
Question
So my environment is Windows server 2008 R2 with php 5.3 and 5.5 installed. I have set fastcgi.impersonate =1
in php.ini, and added the IIS_IUSRS
to the Administrator group (that is not permanent, it was just a temporary action to try and eliminate problems).
If I run:
exec('dir',$output)
$output
shows what I would expect. However, if I run
exec('shutdown -s -f', $output)
I get nothing from $output
, and the machine does not shut down.
No errors/warnings are reported either.
I have tried putting that same command in a .bat file and running
exec('shutdown.bat',$output);
but it produces the same results as running the shutdown command via command line.
If I run the shutdown.bat
file by double clicking it, or if I type the shutdown command in a cmd window, the machine will shut down. So I know that command is good. Obviously there is a higher permissions issue that I am missing, but I have no idea what it is.
Solution