Welcome to WebmasterWorld Guest from 54.205.0.26

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

run .exe

     
3:25 am on May 11, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 14, 2004
posts:197
votes: 0


hi all,
In my IIS, example: I have a php file (index.php), and a .exe file (sample.exe). In my index.php, I have a link or button call 'Run Exe' which I want when user click on it, then sample.exe will be run. Can it be done? Any sample of code?

Thanks in advances.

3:39 am on May 11, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 12, 2005
posts:5966
votes: 0


You should be able to use the program execution functions [us.php.net] to accomplish what you want. :)

This way, you don't even need the executable in the web root, but you can have it below it, too.

3:55 am on May 11, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:July 16, 2001
posts:545
votes: 0


Is sample.exe a cgi compatible program?

Will the user be interacting with the exe, or just causing a chain of events to happen(updating info somewhere else)?

5:16 am on May 11, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 14, 2004
posts:197
votes: 0


I didn't get what I want. Below is my script in php

exec (" run c:/folder/sample.exe",$status);
echo "Exit status code of command is $status";

the out put is "Exit status code of command is Array"

sample.exe is a application program (FoxPro).

Any guides?

7:32 am on May 11, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 14, 2004
posts: 197
votes: 0


I have trued this:
<?php
function cmd($command, $arguments = null)
{
$commandline = '';
foreach(func_get_args() as $word) {
$commandline .= '"' . $word . '"';
}
$commandline = rtrim($commandline, '');
$commandline = '"' . $commandline . '"';
return `$commandline`;

}

if($com=new COM("WScript.Shell")) echo "yes";
$cmd="C:\sample.exe";
if(!$cmd1=$com->exec($cmd))
{
echo "can not exec()";
} else{
echo"can run exec()";
}

I got the answer 'can run exec()' BUT I cannot see the interface of the sample.exe. Anything I have missed in the command?

10:15 am on May 11, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 21, 2004
posts: 54
votes: 0


Hi,

Would I be correct in thinking that running the .exe from PHP will run it in the server and not on the client?

If so you will never get to see the interface because it is being run on the server.

10:44 am on May 11, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 12, 2005
posts:5966
votes: 0


Yes, it is executing it on the server. If you want it to be run on the clients computer, they are going to have to download it either to a temporary file and then "open" it, or "save as" it to their computer and then run it. It should prompt for either of these if they go to the uri where the file is located.
11:23 am on May 11, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 14, 2004
posts:197
votes: 0


thanks for reply.
then is it any alternative ways for me to run the exe at client site?

can it be done if i use patch file to open the exe? but i no idea with path command.....