18

I want to open an exe file through a link in an HTML file.

Is it possible? If so, how?

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Mohammad Dayyan
  • 21,578
  • 41
  • 164
  • 232

11 Answers11

14

On a local computer you can do it with ease, So you have just to Create your own custom protocol, like the one used by Skype or iTunes to launch their native windows applications :

  • Custom protocol has to be created on Windows Registry by adding a entry as the one here :
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\ACCapp]
@="URL:ACCapp Protocol"
"URL Protocol"=""

[HKEY_CLASSES_ROOT\ACCapp\shell]

[HKEY_CLASSES_ROOT\ACCapp\shell\open]

[HKEY_CLASSES_ROOT\ACCapp\shell\open\command]
@="msaccess.exe"

the word in bold ACCapp is the name of the custom protocol that would be used on your html href link as follow

<a href="ACCapp://">PLEASE RUN MS Access exe file</a>
This link won't run unless you add the registry keys.
Wayayay
  • 3
  • 3
Mahfoud Boukert
  • 181
  • 1
  • 5
  • I tried this concept, it come out well but the thing is -my .exe automatically closing after i launch... i didnt get reason – Namitha Dec 06 '21 at 09:46
9

You can not start/execute an .exe file that resides locally on the users machine or through a site. The user must first download the exe file and then run the executable.

RDL
  • 7,865
  • 3
  • 29
  • 32
  • What about javascript, Can we open an exe file with JavaScript ? – Mohammad Dayyan Nov 19 '10 at 04:12
  • 1
    No, it won't work with javascript either. HTML and javascript received from a server are not aware of the users directories or their file paths (nor can they access them). The user still needs to download the file and run it manually. – RDL Nov 19 '10 at 14:22
5

You can do this

it's the only way I see:

<html>
    <head>

        <title>Open exe</title>

        <script type="text/javascript">
        function runProgram()
        {
            var shell = new ActiveXObject("WScript.Shell");                 
            var appITunes = "\"C:\\Program Files\\iTunes\\iTunes.exe\" ";
            shell.Run(appITunes);
        }        
        </script>

    </head>



    <body>

        <a href="javascript:runProgram()">Run program</a>

    </body>

</html>
chenatu
  • 827
  • 2
  • 10
  • 22
mcd
  • 67
  • 1
  • 2
5

Due security reasons it's not possible, and probably it's better it stays that way.

The following code works, but only on the machine which the program exists on:

<a href = "c:\Myfolder\Myprogram.exe">
Wouter Dorgelo
  • 11,770
  • 11
  • 62
  • 80
3

I created an application for this exact purpose. It is called WebRun and you can download it from www.webrunapps.com. After installation you can create a webrun link to launch any executable / file / command on your Windows PC. Here is an example to run notepad:

<a href="webrun:C:\Windows\notepad.exe">Notepad</a>

Hope that helps.

kouts
  • 360
  • 1
  • 4
  • 9
  • 1
    this helped me lot. but i have simple query with me. The webrun is not working in mobile ??? if webrun for android mobile ? – Karthi Feb 18 '17 at 12:44
2

You could write an Active-X object that runs in internet explorer only.

It's not an exe but it's the closest you'll get to running an exe.

1

I know a good answer to this one, Roblox and Atom uses this technique to run exe programs with a link. I have never done this so I can't really explain how to do it but I know how. They use URI protocols. URI protocols are like http, ftp, and https. I don't know Roblox's uri protocol, but I know Atoms, atom's is atom://. I recently just learned of this type of technology so I don't know much about it.

Except, the user must first download the exe files first, than once download, if the uri protocol is set on it, you can open it through a link.

If you have atom installed on your system, here is an example, it will open the program which as I believe is a exe file. This is just a random package I stumble a bond. atom://settings-view/show-package?package=autocomplete-plus

Mahfoud Boukert actually explains this a bit, with some code examples.

0

At work I'm a PC (bummer - I'm a MAC fanatic) and Firefox. The code that worked for me in Firefox, and the link works internally ONLY, was <a href = "file:///c:/Myfolder/Myprogram.exe">.

AND it works ONLY if you right click on the link and select Open Link in Ext.App. Just clicking on the link itself prompts the user to save the .exe file and then run it.

I could not get it 2 work in IE or Firefox with just <a href = "c:/Myfolder/Myprogram.exe">

Shog9
  • 156,901
  • 35
  • 231
  • 235
  • Probably not a great idea to put your email address in your posts here. See also: http://meta.stackexchange.com/questions/5029/are-taglines-signatures-disallowed – Shog9 Nov 22 '13 at 05:46
0

I know a good answer to this one, Roblox and Atom uses this technique to run exe programs with a link.

itch.io is another website that can emulate an .exe file but doesn't require you to download it. Take for example, https://danidev.itch.io/triangle-game, by Dani (a youtuber that i quite like :D). I'm too lazy to dig through file sources but basically, this game was created with Unity. I'm not too sure of this but I think to have an .exe file load on an .html website, you have to use WebGL. (because it was the only option i found when digging through one of Dani's videos that supported exporting a Unity program to HTML5)

Dávid Laczkó
  • 1,091
  • 2
  • 6
  • 25
  • The method used for this comes from the Unity engine itself. It touts its ability to package a game for either desktop or web. Most won't/shouldn't be using Unity for the subject at hand, but those who do are easily able to package their game to be web-runnable. – John Fisher Jan 31 '20 at 00:52
-1

Why not use CGI for this purpose, CGI actually runs the executable through browser on server.

Anshul
  • 360
  • 3
  • 15
-1

Simply provide access to the folder, but do not include the .exe in the href. The user will then just click on the .exe file to open it. Open here where 'targetFolder' holds your .exe file.

AKI
  • 1
  • 1
  • While this is a nice workaround, I'm not sure if it answers the question as you're not opening it via a link in HTML. – JJJ Apr 08 '19 at 22:12