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:
- Use
/
instead, it also work under windows. - If your path contain spaces, wrap it in double quotes
$exec = '"C:/my path/file.exe"';
- Parameters should be passed outside double quotes
$exec = '"C:/my path/file.exe" /help';
- 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
Sending Correct File Size with PHP Download Script
Where Do I Put a Database Query in MVC
Finding Free Blocks of Time in MySQL and PHP
PHP Type-Hinting to Primitive Values
How to Use Http_X_Forwarded_For Properly
How to Give Container as Argument to Services
Where to Put the PHP Artisan Migrate Command
Does PHP Optimize Tail Recursion
Woocommerce Add to Cart Button Redirect to Checkout
Write a Text File and Force to Download with PHP
Do PHP Pdo Prepared Statements Need to Be Escaped