0

I know we can launch .exe file using following code snippet. but this only works for IE. My client very often use Chorome and Firefox as well. How can I modify this snippet to launch the exe from other browsers as well.

var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "C:\User\Desktop\test.exe"; `oShell.ShellExecute(commandtoRun,"","","open","1");`

Also, there any mean to pass any argument to that opening .exe file?

AQ Dev
  • 43
  • 3
  • 14

2 Answers2

1

The best way to achieve this is to have the .exe you want to run register itself with a custom protocol URI Scheme.

For example, lets say you have a program, alert.exe, that will show or send an alert. You could register the URI Scheme alert. Then your link would look like:

<a href="alert:Message to Show">Alert</a>

When the user clicks on the link, the browser will launch your alert.exe and pass the string Message to Show to it.

Martin
  • 15,820
  • 4
  • 47
  • 56
  • I've accomplished this thank you for your comment. But you can help me in another way. That is I want to launch .exe file that is located at network and the link to that file is: \\bisco\root\apps\ABC\ABCNavigator\NavLauncher.exe. I tried by changing backslash to double and even with forward slashes but no luck. Can you please provide some clue to reach out to that file. – AQ Dev Jun 10 '16 at 08:28
  • Have you tried with the network path mapped to a local drive? – Martin Jun 10 '16 at 08:33
  • Maybe try with a mapped drive, map G: to \\bisco\root\apps\ABC\ABCNavigator\ and then change the Scheme command to (Default) = "G:\NavLauncher.exe" "%1" – Martin Jun 10 '16 at 08:45
0

Could an inline script work?

<a href="#" onclick="window.open('file:///C:/User/Desktop/test.exe')">

I'm not sure if you can replicate this on Firefox or Chrome because of security issues.

These links may be helpful:

https://developer.mozilla.org/en-US/Add-ons/Code_snippets/Running_applications

https://developer.chrome.com/extensions/npapi

Maria Saavedra
  • 187
  • 1
  • 5