The php command exec doesn't work

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

The php command exec doesn't work

Postby gianpagi » 31. October 2017 14:26

Hi,
i have a simple script :
Code: Select all
<?php
exec('K:\prova.bat',$out);
echo $out;
?>
where the prova.bat contains :
Code: Select all
c:/windows/system32/notepad.exe


When i run the the php file i don't receive any response from the server

The Apache process is not a windows service and in the php.ini there is no exclusions.
what could be the problem ?
Regards
Gianpaolo
gianpagi
 
Posts: 2
Joined: 31. October 2017 14:08
XAMPP version: 7.1.2
Operating System: Windows

Re: The php command exec doesn't work

Postby Nobbie » 01. November 2017 18:01

You cannot execute .bat files, but .com and .exe instead. To run a batch file, which is interpreted by the command shell only, you must run the command shell and provide the batch file to that shell. The correct syntax should look like this example (i cannot run a test as i dont use Windows anymore):

Code: Select all
exec('cmd /c K:/prova.bat');
Nobbie
 
Posts: 13175
Joined: 09. March 2008 13:04

Re: The php command exec doesn't work

Postby gianpagi » 02. November 2017 08:21

Hi,
thank for your replay.
I tryed but it doesn't work. I have the same beaviour.

Gianpaolo
gianpagi
 
Posts: 2
Joined: 31. October 2017 14:08
XAMPP version: 7.1.2
Operating System: Windows


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 197 guests