r/PHPhelp • • Apr 23 '19

Php cmd command with console

Hi, i want to launch a .bat file. I want to launch it with console. I tried:

system("my_script.bat");

But console doesn't open and the output is printed in my php page.

I also tried:

exec("my_script.bat");

But console still don't open

SOLUTION:

system("start my_script.bat");
7 Upvotes

4 comments sorted by

1

u/Cashman_J Apr 23 '19

I have never done this in windows before, is it finding the file?

<?php exec ('c:\\my_script.bat'); ?>

1

u/secon25 Apr 23 '19

Yes, because the script get launch, but console don't get show

1

u/Cashman_J Apr 23 '19

If you use shell_exec you can see the output, though no windows will pop up.

From: https://www.php.net/manual/en/function.shell-exec.php you can see a couple of resposnses, just Ctrl-f "windows".