-1

How can I make a link that opens a program on somebody's computer?

For clarity: I want chrome/firefox to open the following dialogue: "open MySpecialLinks links with: someprogram.exe", the way that roblox.com does it. enter image description here For instance, something like this:

<a program="someprogram.exe" arguments="file394">Load in someprogram</a>

To run "someprogram.exe" on the computer of the end user.

AnnoyinC
  • 426
  • 4
  • 17

3 Answers3

0

You can't force a program to run, but if you have the .exe stored on your webserver, you can link to it in order for it to download to the client's computer.

<a href="/link/to/someprogram.exe">Download Program</a>
James Grimshaw
  • 307
  • 2
  • 11
  • Makes sense. Is there a way to make "special" links that prompt a "open with" dialogue? I know it's possible, if you look at Roblox.com, you have virtual places where you can press a "play" button in the browser and it will open the roblox program on your computer. – AnnoyinC Oct 27 '19 at 12:45
  • 1
    They will probably have added some code into the Roblox program so that it will detect certain web links and automatically open them in the program. Something along the lines of https://learn.microsoft.com/en-us/windows/uwp/launch-resume/web-to-app-linking – James Grimshaw Oct 27 '19 at 13:02
  • Is that a windows-only solution? I verified roblox app launching also works on linux. I tried to reverse engineer their code but it's obfuscated of course. – AnnoyinC Oct 27 '19 at 13:40
0

The answer turned out to be mime types and url protocols.

Instead of href=https://something, put href=myprogram://something. Now, we just need to tell the browser to open "myprogram" links with a certain program. The program will then parse the "something".

The way you associate mime types and protocols with programs depends on the operating system, answered in this other question:

How do I associate a custom MIME-type to my local application in the major browsers?

AnnoyinC
  • 426
  • 4
  • 17
-1

Short answer: no you can't.

Long answer: you might. If the user is running Internet Explorer and ActiveX is enabled, plus you know the installation path, you might by using:

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

Another possibility would be to use Silverlight, which also works in Firefox if installed and given insane levels of access... (a.k.a. shouldn't happen)

<script>
    dynamic cmd = AutomationFactory.CreateObject("WScript.Shell");
    cmd.Run("calc.exe", 1, true);
</script>

Now the only true option you have, would be to register a custom protocol, which then triggers your program. This can be done as described here: https://support.shotgunsoftware.com/hc/en-us/articles/219031308-Launching-applications-using-custom-browser-protocols

wawa
  • 4,816
  • 3
  • 29
  • 52
  • Might I ask why this was downvoted? Sure ActiveX is at best a huge security hole and Silverlight... well... no one uses it. However registering a custom protocol is the only valid way to launch another program from the browser. – wawa Oct 28 '19 at 21:34