我看了这里回答的以下问题:
How to open file in Mozilla Add-on SDK using system default application
How can I open an external app from Firefox addon? (Eg: default text editor)
Perfom a ShellExecute from Firefox Addon
然而,这些解决方案中没有一个对我有效,我觉得问题可能比我最初想象的更严重。本质上,我正在尝试使用Mozilla插件扩展名启动.jar可执行文件。我的代码如下所示:
var buttons = require('sdk/ui/button/action');
var button = buttons.ActionButton({
id: "execute-jar",
label: "Download Report",
icon: {
"16": "./icon-16.png",
"32": "./icon-32.png",
"64": "./icon-64.png"
},
onClick: handleClick
});
function handleClick(state) {
let {Cc, Ci} = require('chrome');
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
file.initWithPath("C:\Users\QaziWa\DownloadReportPPE.jar");
console.log(file);
if(file.exists()){
file.reveal();
file.launch();
}
else {
console.log('Failed.');
}
}
由于某种奇怪的原因,我的.jar文件没有被检测到,我无法理解为什么。我希望有人能提供任何意见,说明为什么会这样。