I want to execute a .exe file on my Apache server using a php script. the procedure is as follow:
user comes, fills a html form
it goses to a php script
php script executes the name.exe
file
php prints the output of the name.exe
file on the page.
I execute the name.exe normally from windows like this:
run--> cmd--> D:\name [command]
the name.exe needs to communicate with other files like libraries in the same directory.
the complete comand in cmd at windows is like this:
D:\name library.dll [input from user]
then program executes and prints some results in cmd window.
I actually want to run this program on my server form my clients. I don't know how, but I now there is a way to do this.
Another related question, is there any shell that I can install on Linux server and execute name.exe in it?
You can only run exe files if your php is runnning on a Windows machine. Futhermore, if you are on shared hostig, your hoster may have disabled the exec command. If you are on a Windows machine, 'abc.exe' must be in the current directory or in the PATH. Ya.
Double-click an EXE file to run it. EXE files are Windows executable files, and are designed to be run as programs. Double-clicking any EXE file will start it. If the EXE file was downloaded from the internet, you'll be asked to confirm that you want to run it.
So you really can't launch .exe files from a browser with any much success - it simply a security hole the size of open barn door. You might get some success opening up some trusted locations for the browser - but it is a difficult challenge at best.
Please rethink your solution as this will likely create more problems (particularly security issues) than it solves. By having a PHP script execute your program you run the danger of a user entering the following into your form:
John Doe; rm \windows\*
or
John Doe; rm d:\name\*
You want to limit user input to a very controlled subset so that you won't get malicious command injection.
PHP does provide an exec()
but be very careful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With