Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run abc.exe using php

Tags:

file

php

exe

I want php file to run exe file and display the exe file content when user goes to a particular url. I am trying to run exe file using php function exec('abc.exe');. But I only see blank page.

Anyone know how to solve it or how to run exe file from php file correctly? Many thanks in advance.

like image 590
ATZ Avatar asked Sep 03 '12 16:09

ATZ


People also ask

Can PHP run EXE file?

You can run any command you want using exec or shell_exec in php.


2 Answers

To access the operating system with php you do the following

$answer = shell_exec("abc.exe");
echo $answer."</br>"; 

The $answer string will contain the information that the abc.exe prints out or returns.

You may need to format it using explode().

like image 52
KennyBartMan Avatar answered Oct 28 '22 03:10

KennyBartMan


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.

To capture the output use:

exec( 'abc.exe', &$output);
echo $output;

Link to exec

like image 4
JvdBerg Avatar answered Oct 28 '22 03:10

JvdBerg