How to exec a external Windows Prog ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DarK DragoN
Forum Newbie
Posts: 3
Joined: Sun Jul 13, 2003 7:39 am

How to exec a external Windows Prog ?

Post by DarK DragoN »

Hi

I want to exec a Windows Prog. from php so that this prog started on my local System

like this :

c:\Progamme\wincmd\wincmd.exe

the prog must be started on my local PC not on Server

I've tested with system(), passthru(), popen(), escapeshellcmd()
but nothing of them starts my windows prog

If anyone can help

thanks for
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

DarK DragoN
Forum Newbie
Posts: 3
Joined: Sun Jul 13, 2003 7:39 am

Post by DarK DragoN »

I tested it with exec() too

I only forgett to write it in post over

but with exec nothing
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Read some of the user notes for Windows on the exec() page. It didn't work for me at first but the notes solved the problem.
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

the prog must be started on my local PC not on Server
The 'local PC'?
You mean a client with that?
alexus
Forum Contributor
Posts: 159
Joined: Fri Jul 04, 2003 10:49 pm

Post by alexus »

I did it by using system(), cmd (Linux, XP, 2000, 2003) and the path to your program…

It might not work on your computer if you don’t have proper permissions for internet user…
I have no idea how to deal with Linux, but on windows you just go and set execute permission for I_USER (or something like that), and also don’t forget to allow execute files on your web site in IIS manager…

But again I’m 100% windows person so I can’t speak about other then MS products…
DarK DragoN
Forum Newbie
Posts: 3
Joined: Sun Jul 13, 2003 7:39 am

Post by DarK DragoN »

yes to redhair

client pc ;)

this is the code

Code: Select all

$prog="D:\Programme\flashfxp2\FlashFXP.exe";
  $data=$username.":".$password."@".$host.":".$port.$path;
  $getdata = $prog." ".$data;

  $process2=exec($getdata);
if(!$process2) {
    echo "<p>Error : bla bla bla</p>"; 
&#125;
no flashfxp.exe starts

All the manuals I found are self than php manual and there is nothing about exec under Windows

My System runnig Server and php

Win2k Server
Apache 2.x
php 4.3x
alexus
Forum Contributor
Posts: 159
Joined: Fri Jul 04, 2003 10:49 pm

Post by alexus »

Like I said try to set execute permission for folder D:\Programme\flashfxp2\
For “IUSR_<machine_name>”

In users list just find IUSR_... it is only one there,

If you wouldn’t do it win 2000 will block the command and return 404.2 error

PS: unless you have default permission set, (all everything for everyone){in that case I sagest you to remove EVERYONE group and set up proper permission for your folder, just for security reasons…)
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

make the server side script execute something on the local client? that is possible with stuff like vbscript and very insecure/trusty settings on the client.. PHP itself can not execute something on a remote machine
alexus
Forum Contributor
Posts: 159
Joined: Fri Jul 04, 2003 10:49 pm

Post by alexus »

Well if he is talking about remote machine, you can still do it and you still have to use CMD console:

You can play with NET command (search Microsoft or TechNet for NET or NET USE), it might help you to get what you want, but tactically it will look like you are trying to hack your client machine through the web interface… and power of the server…
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

As said, php can not start something on a client.
...simply because php is server based.

You must have some sort of client running on the client machine, wich will be activated when the php script on the server machine 'asks' something of the client machine.

For example...you could install php/apache on the client...have the server retreive a script on the client machine, and let that script execute something on the client machine.
alexus
Forum Contributor
Posts: 159
Joined: Fri Jul 04, 2003 10:49 pm

Post by alexus »

To: redhairyes.

Yes, PHP can't run e program but win2000 can, and he is running win2000...

And PHP can execute conslole command on server, so if he will use propper console command he can force the client machine to start app...
User avatar
redhair
Forum Contributor
Posts: 300
Joined: Fri May 30, 2003 4:36 pm
Location: 53.23N-6.57E
Contact:

Post by redhair »

alexus wrote:And PHP can execute conslole command on server,...
....so the client must be running some sort of client app.
alexus
Forum Contributor
Posts: 159
Joined: Fri Jul 04, 2003 10:49 pm

Post by alexus »

To redhair: yes and no, if the client has win2000, XP, or 2003 then you just can play with console ( yes it is no so many things you can do with it, but still)... Well if the client is running Me, 98, 95, 3.1 there will be big limitation on remote controll and remote managment... (And I have no ideas about linux, unix, sun, hp, palm, mac - those platforms are out of my certification...)
Tubbietoeter
Forum Contributor
Posts: 149
Joined: Fri Mar 14, 2003 2:41 am
Location: Germany

Post by Tubbietoeter »

You can do this with php, if you got telnet running.

See the link for details:

http://www.devnetwork.net/forums/viewto ... highlight=
Post Reply