How to run a system command through Javascript in Google Chrome?

I want to execute a local program on my computer using Javascript in Chrome. In Firefox, this can be done as follows (after setting "signed.applets.codebase_principal_support" to true in about: config):

function run_cmd(cmd, args) {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

    var file = Components.classes["@mozilla.org/file/local;1"]
        .createInstance(Components.interfaces.nsILocalFile);
    file.initWithPath(cmd);

    var process = Components.classes["@mozilla.org/process/util;1"]
        .createInstance(Components.interfaces.nsIProcess);
    process.init(file);

    process.run(false, args, args.length);
}

What is the equivalent code for Chrome?

+5
source share
4 answers

This is not possible in Chrome without extensions. This requires an NPAPI plugin in extensions, see http://code.google.com/chrome/extensions/npapi.html ,

+1
source

I do not think you can. Chrome is very relevant to such things, so their sandbox

0
source

Chrome Native Messaging Chrome. NPAPI .

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

0
source

Javascript is unable to communicate outside the browser. For example, there is no disk I / O, there is no connection with the main OS, such as Windows / Linux. Javascript is inherently tougher since it is executed by the browser itself.

-3
source

All Articles