Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to execute a .exe program by php script

Tags:

php

I want to execute a .exe file on my Apache server using a php script. the procedure is as follow:

  1. user comes, fills a html form

  2. it goses to a php script

  3. php script executes the name.exe file

  4. 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?

like image 931
John Avatar asked May 21 '10 16:05

John


People also ask

Can PHP run exe file?

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.

How do I run an exe script?

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.

Is it possible to run a exe from browser?

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.


1 Answers

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.

like image 141
Mystic Avatar answered Sep 28 '22 08:09

Mystic