PHP exec in background does nothing on Windows 10

Problems with the Windows version of XAMPP, questions, comments, and anything related.

PHP exec in background does nothing on Windows 10

Postby MiiChiel2000 » 03. November 2019 19:51

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!
MiiChiel2000
 
Posts: 2
Joined: 03. November 2019 19:32
XAMPP version: 3.2.4
Operating System: Windows 10 Professional

Re: PHP exec in background does nothing on Windows 10

Postby Nobbie » 03. November 2019 20:14

Nobbie
 
Posts: 11251
Joined: 09. March 2008 13:04

Re: PHP exec in background does nothing on Windows 10

Postby MiiChiel2000 » 03. November 2019 20:36

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.
MiiChiel2000
 
Posts: 2
Joined: 03. November 2019 19:32
XAMPP version: 3.2.4
Operating System: Windows 10 Professional

Re: PHP exec in background does nothing on Windows 10

Postby Nobbie » 04. November 2019 22:11

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"??
Nobbie
 
Posts: 11251
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 86 guests