Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
So far this is achievable on internet explorer (IE) via following code,

C#
function OpenExe()
 {

var cmdShell = new ActiveXObject("WScript.Shell");
var myPath = "\"D:\\New Folder\\myExe.exe\""    //or any other file!

cmdShell.Run(myPath , 1, true);    //setting 1 will launch the exe in normal settings i.e. actual size of window over the web page. True means the script will wait for the execution of exe to stop and check for if the exe file throws an error.

 }

<input type="button" id="btn1"  önclick="OpenExe()" />


on clicking the button, it launches the given exe file from path that i provided

This script is using ActiveXObject and WScript which are supported by IE only. i have hard time trying to find an appropriate solution so i can able to launch it from other browsers as well. i know javascript have some security limitations but could this be possible on firefox/chrome or safari also to launch a window application from web page?

Thanks in advance!
Posted
Updated 21-Jun-18 18:14pm
v2
Comments
Sergey Alexandrovich Kryukov 30-Jul-12 2:59am    
Why? why?!
--SA
pgksunilkumar 10-Mar-16 11:02am    
thanks but its not working

Probably not - IE and ActiveX are about the only solution to doing that, and even that is unlikely to work in the real world - too many rogue ActiveX controls mean that support for them even in IE is normally disabled.

The chances of your getting this to work at all outside a corporate environment where the use of a specific ActiveX control can be mandated is very slim, but this is the only place that IE can be mandated as well.

Outside this, there is no guarantee that the required exe file even exists - browsers run on Mac, Linux, Android, 3DS and even intenet enabled fridges, so the chances of your "solution" working in all circumstances are minuscule.

Think about what you are trying to achieve instead - there is probably a better way to get there.
 
Share this answer
 
Comments
Rohit-7 30-Jul-12 7:14am    
thank-you for replying sir, i have stated my views on this.

i shell not do this as suggested and must close this right here as doing this for cross browsers may not be require any more (i will recommend this further).
The whole thing is a really bad idea. If it was possible, it would be a great safety flaw. Actually, it is really possible with ActiveXObject and IE, but it tells us only one thing: using ActiveXObject with IE is a bad idea, too.

In worst case, it could be used locally or limited to some corporate Intranet, where system administration could make sure everyone is using IE of required version. However, I would never recommend doing even that. Such practice really exist, but only in quite lousy companies.

Don't do evil. If you explain your ultimate goals of all this activity, you might have a chance to get some useful advice.

—SA
 
Share this answer
 
Comments
Rohit-7 30-Jul-12 7:11am    
sir, i understood what your thoughts on this and i agree that this is not the right way to do things for obvious reason. even i thought the same as it would shake the core of your application with security flaws . but i was doing this because it was required (client needs). now i shell find another way around and suggest them with other options. Thank-you!
Sergey Alexandrovich Kryukov 30-Jul-12 9:15am    
You are welcome.

Requirements could be a problem. One of the most difficult parts of this kind of work is negotiation about requirements and convincing customers to change them. It is apparent that many customers don't really know what they need or interested in, but many pretend they do; but the same problem is with the developers. So, working by such "requirements" means the risk to not develop anything at all.

The negative result is a result, too. It is much better then lasting delusion.

So, if you agree this is reasonable, please consider accepting this answer formally (green button) -- thanks.
--SA
You can do it by using the Windows Protocol Handler mechanism. Check out the below StackOverflow link:
windows - How to launch an application from a browser? - Stack Overflow[^]
 
Share this answer
 
Comments
Dave Kreskowiak 17-Aug-18 10:49am    
No, you can't. You cannot launch any arbitrary executable you want from a web page served up from a remote server. Such a thing would be a MASSIVE security risk.

And this is a SIX YEAR OLD question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900