Execute external program ( like skype.exe) using php
Solution 1
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.
Solution 2
This will never work AFAIK, even if you do a 'login as admin' command first to make sure you have admin rights, there is no way to execute an external .exe file.
Related videos on Youtube
Ananth
I am Full Stack Developer. Thirsty for coding and solving complex issues. I'm have around 8 years of experience. Spent most of my days in Cricket. Loves watching animation movies. I'm good in Web developing technology. I'm an good artist too. In my childhood, i love to do pencil drawing and painting when i got time. I'm really lazy, so i always want to code short and smart. I work hard if it is really required, otherwise i will do smart works. I love my family and my friends. I learn a lot from my friends when i came out of my home. I love this Bangalore and Madurai.
Updated on June 04, 2022Comments
-
Ananth almost 2 years
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 : 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\" ");
-
Admin almost 10 yearsDid you tried to run it in background ?
start /B program.exe
-
Ananth almost 10 yearsI have tried with start /B , it is not working. I have updated my question with sample codes
-
sertsedat almost 9 yearsdid you try threading?
-
-
Ananth almost 10 yearswhen i use this exec('"C:\Program Files (x86)\Hewlett-Packard\HP MyRoom\MyRoom.exe" ');, it wil working fine. But the issues is , it is not stoping execution of the php script, until the application closed
-
Kevin Op den Kamp almost 10 yearsTrue but that has nothing to do with running the command from PHP using exec or similar. It just won't work, probably for security reasons. It took me ages to come up with a workaround as I had a similar problem: stackoverflow.com/questions/21731033/… Some suggest giving admin rights to PHP/apache etc. but this doesn't change a thing...not for me at least
-
Ananth almost 10 yearsactually, the above code is working, But the issues is that i have to execute several other code next to the exec function. But when i use exec(), the execution stops at exec , it is not moving to next line. Ex: exec(); echo "Success" ; . In above example it output success. it is in loading stage only.
-
Tushar Dave almost 10 yearswell the closes solution to this as far as i think would be to 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. i have also edited my answer for this
-
Ananth almost 10 yearsYeah. In my question, i mentioned that issues with exec already. I want to echo the "after quitting the program" text before quitting the program