Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I launch a system command via Javascript in Google Chrome?

I want to execute a local program on my computer via Javascript in Chrome. In Firefox, it 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's the equivalent code for Chrome?

like image 390
user103113 Avatar asked Nov 26 '22 19:11

user103113


1 Answers

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

like image 163
Ming-Tang Avatar answered Dec 18 '22 23:12

Ming-Tang