I need to execute a .exe file located in C:\Program Files\ABC\test.exe on my windows machine using PHP. I have installed WAMPP/XAMPP to run PHP. I have tried the exec() system() shell_exec() but I'm unable to run the file. Can someone help me with the exact code?

have you tried passthru() it is similar to the system command. If it does not work then it is probable that these command are disabled by your hosting provider.

Can you provide me the exact code of passthru() ?
I am using WAMPP on my local machine to test it. If the commands are disabled, can you help me identify and enable them?

Why would you want to run exe on local file system?
Can't it be accomplished via pure PHP solution?

I need a execute a windows application from PHP. My whole website will be placed on a web hosting, just one process will run from my local system which will act as a web server and execute the windows application.

system("*:/***.exe");

I did some experimenting with Exec.

I had no problem starting a local program with Exec with one exception. If the path name contains a blank, I wasn't able to get it to work. Even if the actual program name contains a blank, it works. One simple example that worked was:

$addr = "c:/Temp/TSP/TSP2.exe";
exec ($addr,$output, $return);

$output has the display output from the program if it is writing to the current window. If it opens in its own window then you see the output there. An example of getting the output from the current window is as follows:

exec("ping google.com", $output, $return);
    echo "The command returned $return, and output:\n";
    echo "<br><br><b>PING </b><br><pre>";
    echo "<pre>";
    var_dump($output);
    echo "</pre>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.