1

So i got a c# desktop app that i wrote over in a website as well. I want to add a button in the login screen to give users the option to open the desktop application.. i am willing to write plugins if needed i just don't know where to start with this i know that Team speak did this as u can go and see on www.forcekillers.com so i know that it is possible.

if have tried what i could find on the web without success here is an example i got to open notepad but also does not work.

<script>
    $(document).on('click', '#butWindowsApp', function (e) {
        var win_app = new ActiveXObject("WScript.shell");
        win_app.run("notepad.exe", 1, True);
    });
</script>

Thanks in advanced

Arno4Jackie
  • 331
  • 1
  • 20
  • Look into Click-Once. Normally, web code can't execute local code. That's for security reasons. – David Crowell Jun 23 '14 at 13:19
  • This may also help you: http://stackoverflow.com/questions/1780211/how-does-the-apple-itunes-web-site-launch-the-itunes-application-on-my-computer – Dan Drews Jun 23 '14 at 13:19

1 Answers1

6

Those kinds of applications (e.g., uTorrent and magnet links, github.com launching GitHub For Windows etc), usually define a URI scheme and register a protocol handler on the client's computer.

For example, here's a few sample URIs:

//magnet link
magnet:?xt=urn:sha1:YNCKHTQCWBTRNJIV4WNAE52SJUQCZO5C

//team speak
ts3server://ts.forcekillers.com/?port=9987

You'll have to run an executable or a .reg file on the client's computer to register your application as a protocol handler for that URI scheme.

Then, your ASP.NET application can redirect the user to a URI like that. The browser will notice that there's a protocol handler associated to that URI and ask the user if he wants to launch that application.

See:

  1. Registering an Application to a URI Scheme
  2. How can I add a custom url handler on Windows. Like iTunes itms://
Community
  • 1
  • 1
dcastro
  • 66,540
  • 21
  • 145
  • 155