1

I developed a web application hosted on a Linux server (or Windows for some clients). I use Angular 6 for the frontend and Spring Boot for the Backend.

So each user uses Firefox to connect to the app. So far so good.

However, I have to develop a new feature that allows the user to open a software installed on his own computer (Windows) from my web app ...

So I have to do this on the client side of my app (Angular or Javascript pure) to launch the software.

I know this is forbidden for security reasons except perhaps if we add an exception in the security of FireFox.

I tried the following code, isolated in a javascript file:

function launchDict(nom) {
  require(['child_process'], function (child_process) {
    //fs and child_process are now loaded
    var exec = child_process.exec;

    exec('C:\\PuTTY\\putty.exe', function (error, stdOut, stdErr) {
      alert("Appel logiciel");
    });
  })
}

How to do that?

****** Update ****** It seems like javascript way is a "bad way" because of security compliance. And solutions described seem to work only on IE example : Is it possible to run an .exe or .bat file on 'onclick' in HTML

anakin59490
  • 630
  • 1
  • 11
  • 28

1 Answers1

2

I don't believe it's possible due to the security risks, but as a workaround you could create a downloadable shortcut file with the parameters already inside it. It is an additional step for the user to click on the downloaded .lnk, but since it appears you already know the path to the executable on their local machine it should at least work.

  • Good idea ! But how can I do to create such file ? Other idea : do you think we can use java applet ? – anakin59490 Feb 14 '19 at 23:21
  • I'm not familiar with the capabilities of a java applet, so I can't answer there. Just create the file on a machine with the standard application installation (right-click, create shortcut) and upload the file. – Paul LeBlond Feb 18 '19 at 19:38
  • You can also use a [custom URL protocol](https://stackoverflow.com/questions/80650/how-do-i-register-a-custom-url-protocol-in-windows) to launch an `.exe` from a web page. – Anderson Green May 05 '22 at 23:33