The $return
value is the value the program returns. In Windows, the return values 0 and 1 is usually used to indicate success, so you can easily tell when the termination was successfull.
However, a return value of 128 is arbitrary, meaning that the program developers of taskkill
decided on it themselves. 128 likely means that the process doesn't exist.
There does not seem to be any documentation that documents the return values of taskkill
, unfortunately.
If your goal is to prevent uper.exe
from being present, a return value of 128 and 1 would then both be acceptable, and your code becomes:
function kill_hr()
{
exec("taskkill /IM uper.exe", $output = array(), $return);
return $return == 1 || $return == 128;
}
The function will return true
if uper.exe
was successfully terminated, or if it wasn't running in the first place.
Edit: Re-reading your post, you can try the following; use runas
to start a command prompt as your web server user (from an administrative command prompt):
runas /user:account@machine cmd
Then you will have a command prompt running as your web server, and you can issue the taskkill
command from there. Then you will likely see a textual error message.