Search code examples
javascriptgreasemonkeylocal-files

Launch local executable from greasemonkey


Below is the code I am trying (plus a few variations), there is a dialog asking for my permission, but still errors out with

Error: Permission denied for to get property XPCComponents.classes

unsafeWindow.netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); 

var file = unsafeWindow.Components.classes["@mozilla.org/file/local;1"]
    .createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("d:\\test.bat");

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

var args = ["argument1", "argument2"];
process.run(false, args, args.length);

Is this just going to be impossible?


Solution

  • You can't. See Do Greasemonkey scripts have chrome privileges?.