Running .Exe from JavaScript

Running .exe from Javascript

You need to escape the backslashes, e.g.,

var commandtoRun = "C:\\Documents and Settings\\User\Desktop\\ABCD.exe";

Update:

This works fine on my machine:

var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "C:\\Windows\\notepad.exe";
oShell.ShellExecute(commandtoRun,"","","open","1");

Update 2

You can save this as a file with the extension .hta and it should work in your browser:

<HTA:APPLICATION ID="oMyApp" 
APPLICATIONNAME="Application Executer"
BORDER="no"
CAPTION="no"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
SCROLL="no"
WINDOWSTATE="normal">

<script type="text/javascript" language="javascript">
var oShell = new ActiveXObject("Shell.Application");
var commandtoRun = "C:\\Windows\\notepad.exe";
oShell.ShellExecute(commandtoRun,"","","open","1");
</script>

How to run windows .exe application from javascript

check this out:

How to run local program (exe) via Chrome via HTML/javascript

lets take for example zoom app:

this is the windows registry: registry imag
you can see the windows registry by typing reg in windows search.
there open the "HKEY_CLASSES_ROOT" by clicking the arrow next to it,
and then look for "zoommtg", and you will get working example that you can examine!

and this is the zoom webpage to launch the zoom app:
zoom webpage

How to run an exe file using java script at runtime

If you want to open external files, then you should use the built-in child_process module.

var { exec } = require("child_process");//the function acts like a shell, so just use shell commands.exec("cmd.exe");

Execute an exe file using node.js

you can try execFile function of child process modules in node.js

Refer:
http://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback

You code should look something like:

var exec = require('child_process').execFile;

var fun =function(){
console.log("fun() start");
exec('HelloJithin.exe', function(err, data) {
console.log(err)
console.log(data.toString());
});
}
fun();

How to run an .exe from a .html button

How to run an .exe from a .html button

You can't. At least, not directly.

However, you can register a protocol handler:

web+yourapp://do-some-thing

When invoked, your executable will launch and be passed this URL, which you can then parse and decide how to handle.

How you register the protocol handler is dependent on what OS you're using. See also: How to register a url protocol handler in Node.js



Related Topics



Leave a reply



Submit