Wampserver - Accessing Windows cmd.exe and running a file. bat

Asked

Viewed 211 times

0

Good morning, everyone,

As stated in the title, I need to access windows cmd.exe through Wampservere and run a .bat. I did the following Cód. php to run the above:

<?php
$batname = "chamaCalc.bat" ; 
$output = shell_exec("c:\\windows\\system32\\cmd.exe /c $batname"); 

echo $output; 
?>

I was successful with my need in Xampp, but in Wampserve, nothing happens. Does anyone know if there’s any way this works at wamp?

Thank you!

1 answer

-1

The problem must be the safe-mode that is active

The solution is:

stop all Wamp-Server services and close the program

Open... / wamp / bin / apache / Apache2 .. / bin / php.ini Copy php.ini for desktop and

define safe_mode_exec_dir (line after = is empty, then it is on) put to Off!

Hail

Copy back to dir (maybe you need administrator rights) restart wamp-server

EDIT

Another solution would be to try to use the function system();

  • Does it matter where the line " safe_mode_exec_dir = off " is defined within php.ini? I set this parameter on the last line of the file but it didn’t work. :(

  • So normally this line already exists, no need to add

  • This line did not exist in my php.ini =(

  • I know there is also an option on the icon on the taskbar that enables or disables host interactions, let me inform you a little more because I no longer have wamp installed

  • Then other things to check would be Wamp running as administrator If you changed apache2 php.ini and not the one in php Also check that in the php file there is no 'disable_functions' line with these functions marked I tried here on my side and it worked after adding 'safe_mode_exec_dir = off'

  • I tried everything you said, but it doesn’t work. My wampserver php is 7.2.18. I don’t know if this can influence anything.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.