Execute external program ( like skype.exe) using php

Ananth picture Ananth · May 26, 2014 · Viewed 11.1k times · Source

I have tried launch an external application installed in the C:\Program Files (x86)\Hewlett-Packard\HP MyRoom\MyRoom.exe using php.

SAMPLE 1 : I'm using exec function and popen and system. But exec function is not executing the code next to the exec command until the application is closed.

**CODE :** 
exec('"C:\Program Files (x86)\Hewlett-Packard\HP MyRoom\MyRoom.exe" ');

SAMPLE 2 : WHen i use the popen ,it is displaying a cmd window instead of application.

CODE : 

pclose(popen('start   "C:\Program Files (x86)\Hewlett-Packard\HP MyRoom\MyRoom.exe" ' ,'r'));

OR

system(' start "C:\\Program Files (x86)\\Hewlett-Packard\\HP MyRoom\\MyRoom.exe"  ');

OUTPUT : enter image description here SAMPLE 3 :

When i user this code, it is return string output.

CODE :

system(' start /B "C:\\Program Files (x86)\\Hewlett-Packard\\HP MyRoom\\MyRoom.exe"  ');

OUTPUT :

Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved. C:\xampp\htdocs\projects\drupal\hpedu\reference>
Any help would be greatly appreciated. 

SAMPLE 4 :

WHen i try this code, it is not returning anything.

CODE :

  exec("start /B  \"C:\\Program Files (x86)\\Hewlett-Packard\\HP MyRoom\\notepad++.exe\\MyRoom.exe\"  ");

Answer

Tushar Dave picture Tushar Dave · May 26, 2014

try

exec('"C:\Program Files\FileZilla FTP Client\filezilla.exe"');

as it is working on my end.

also for script to stop execute try putting a "exit;" after exec command. and if u wnat to execute lines written after exec command then use

exec('"C:\Program Files\FileZilla FTP Client\filezilla.exe"|at now'); 
echo "after quitting the program"; 

but it would work only after the executed program is closed.