skip to Main Content

i’m developing a PHP APP and i need run a external program from a form, i know i need use EXEC function, but my exec function its not working, i check the antivirus and firewall and there is not bloking, this my code, its supposes work but not for me.

var_dump(exec('cmd.exe /K notepad.exe'));

this just keeps the chrome loading forever, i try diferents versions of this code and even format my pc, but nothing its working, pls help

sorry for my english, i speak spanish

2

Answers


  1. I’d try giving popen() a go, like so:

    var_dump(popen('notepad','r'));
    
    Login or Signup to reply.
  2. The problem you are running into is PHP won’t stop executing until it’s sub-processes have quit. Notepad.exe won’t quit until you manually close it so php will never stop running until it times out.

    If you are trying to launch the program into the background on Windows so that PHP won’t wait for it you can use the Windows start /b command

    exec("start /b notepad");
    

    Here is another question that may help you:
    https://stackoverflow.com/a/10898943/2666293

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search