How to launch an EXE from Web page (asp.net) How to launch an EXE from Web page (asp.net) asp.net asp.net

How to launch an EXE from Web page (asp.net)


This assumes the exe is somewhere you know on the user's computer:

<a href="javascript:LaunchApp()">Launch the executable</a><script>function LaunchApp() {if (!document.all) {  alert ("Available only with Internet Explorer.");  return;}var ws = new ActiveXObject("WScript.Shell");ws.Exec("C:\\Windows\\notepad.exe");}</script>

Documentation: ActiveXObject, Exec Method (Windows Script Host).


How about something like:

<a href="\\DangerServer\Downloads\MyVirusArchive.exe"   type="application/octet-stream">Don't download this file!</a>


You can see how iTunes does it by using Fiddler to follow the action when using the link:http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=80028216

  1. It downloads a js file
  2. On windows: the js file determines if iTunes was installed on the computer or not:looks for an activeX browser component if IE, or a browser plugin if FF
  3. If iTunes is installed then the browser is redirected to an URL with a special transport: itms://...
  4. The browser invokes the handler (provided by the iTunes exe). This includes starting up the exe if it is not already running.
  5. iTunes exe uses the rest of the special url to show a specific page to the user.

Note that the exe, when installed, installed URL protocol handlers for "itms" transport with the browsers.

Not a simple engineering project to duplicate, but definitely do-able. If you go ahead with this, please consider making the relevant software open source.