Page 1 of 1

PHP exec in background does nothing on Windows 10

PostPosted: 03. November 2019 19:51
by MiiChiel2000
Hello there,

I am really happy with XAMPP, only I just am not able to run any php exec command in the background or at all. So I tried:

- starting XAMPP as admin
- Install services (without services installed exec command does work with applications, not with batch files, but they don't run in background, with services the whole exec command does not work)
- put UAC to lowest setting
- Making a test.php:

Code: Select all
exec('cmd /c C:/test.bat',$output,$return_val);
if($return_val !== 0) {
    echo 'Error<br>';
    print_r($output);
}


Result is:
Code: Select all
Error
Array ( [0] => [1] => C:\xampp\htdocs>echo hoi [2] => hoi [3] => [4] => C:\xampp\htdocs>timeout 5 )


The test.bat file contains:
Code: Select all
echo hoi
timeout 5


Same with normal applications. They don't start at all when Apache as services is installed. Only normal applications (no .bat files) run when services is not installed.

I tried changing in services the service can interact with the desktop, no change. I don't know to which user i should change it (the not local one), cause there is none, the user field is blanc.

Can someone help me out? Thnx!

Re: PHP exec in background does nothing on Windows 10

PostPosted: 03. November 2019 20:14
by Nobbie

Re: PHP exec in background does nothing on Windows 10

PostPosted: 03. November 2019 20:36
by MiiChiel2000
Nobbie wrote:Sinply read the documentation

https://www.php.net/manual/de/function.exec.php


Well I did. I know that giving an extra parameter makes it work in the background. Except it doesn't work for me, like I described before, I tried all different kind of solutions that people came up with.

When I close the application, for instance mspaint, then the server continues working out the rest of the php file.

Re: PHP exec in background does nothing on Windows 10

PostPosted: 04. November 2019 22:11
by Nobbie
MiiChiel2000 wrote:
Nobbie wrote:Sinply read the documentation

https://www.php.net/manual/de/function.exec.php


Well I did. I know that giving an extra parameter makes it work in the background


Uuh?! Why do you believe that, what makes you "knowing"??

Actually, I know that REDIRECTING the output makes it work in the background, and nothing else?! What do you mean by "giving an extra parameter"??