2

I am wondering if there is a way to launch on windows locally stored executable (with arguments) from web browser (not on localhost). Something equivalent to .net:

Process.Start("\\path\to\exe\foo.exe", arg1, arg2,..).WaitForExit()

Hopefully generic way to use in any of major browsers.

goryef
  • 1,337
  • 3
  • 22
  • 37

2 Answers2

4

Browsers do not have this feature. Otherwise, anyone could run malicious code on users' computers. Such an opportunity is only for local instruments like Electron or Node.js, where JS process has bindings to a local file system.

Trop
  • 316
  • 1
  • 2
  • 10
  • My app is actually Node.js. Can you point me to any examples of binding to local system. Thanks – goryef Aug 17 '19 at 13:22
  • Node.js allready has that bindings. You need just run process - https://stackoverflow.com/questions/20643470/execute-a-command-line-binary-with-node-js – Trop Aug 17 '19 at 13:24
  • Can I run file stored on clients machine from child process? – goryef Aug 17 '19 at 13:30
  • 1
    Yes. Child process can be written in any language, uncluding node.js, and in its code you can write any operations with files. – Trop Aug 17 '19 at 13:33
  • On Windows, it is possible to launch executables from browsers using [custom URL protocols](https://stackoverflow.com/questions/80650/how-do-i-register-a-custom-url-protocol-in-windows). – Anderson Green Jan 06 '22 at 02:12
1

As mentioned by Pavel, you cannot execute the code directly. Either you need to run something like node.js or you could have a local server like xampp installed. This will let you run PHP, which in turn would call the DOS /CLI commands to execute the local executable.