Click here to Skip to main content
13,145,568 members (46,022 online)
Rate this:
Please Sign up or sign in to vote.
So far this is achievable on internet explorer (IE) via following code,

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 29-Jul-12 20:33pm
Updated 30-Jul-12 0:59am
Why? why?!
pgksunilkumar 10-Mar-16 11:02am
thanks but its not working
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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.
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).
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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!
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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 8 Jul 2016
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100