How to Run Abc.Exe Using PHP

Executing an exe file using php on server error

To be able to access $_GET['cmd'] you need to pass in request parameter with that name. In your case something like: demo.com/index.php?cmd=C:\path\AUTORUN.exe
Also: running application from request parameters is really bad from security point of view.

Can't run .exe files using exec() in PHP

Few advices that may help:

  1. Use / instead, it also work under windows.
  2. If your path contain spaces, wrap it in double quotes $exec = '"C:/my path/file.exe"';
  3. Parameters should be passed outside double quotes $exec = '"C:/my path/file.exe" /help';
  4. Make sure that your program actually writes to STDOUT, not STDERR.

How to use PHP to call another CLI.exe process I/O in linux?

If you want to communicate with the process via STDIN/STDOUT, you'll need to spawn it from PHP using proc_open, which gives you access to these pipes.

To more closely match what you ask, I'd suggest named pipes or unix sockets. If your CLI.exe is the parent, it would use the mkfifo system call to create the named-pipes. PHP has some good documentation here.

Another alternative on *nix platforms is Unix Domain Sockets. Typically these are files named with the .sock extension under the /var/run folder (or subdirs).



Related Topics



Leave a reply



Submit