执行带有 Mozilla 扩展名的 .jar 文件
Execute .jar file with a Mozilla extension
我查看了此处已回答的以下问题:
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
然而 none 这些解决方案对我有用,我觉得问题可能比我原先想象的要深。本质上,我正在尝试启动一个带有 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) {
// try {
// var file = Services.dirsvc.get("Desk", Ci.nsIFile);
// file.append("C:\Users\QaziWa\DownloadReportPPE.jar");
// file.launch();
// }
// catch (ex) {
// console.error("failure");
// Failed to launch because e.g. the OS returned an error
// or the file does not exist,
// or this function is simply not implemented for a particular platform.
// }
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 文件没有被检测到,我不明白为什么。我希望有人可以提供任何意见,说明为什么会这样。
改变
file.initWithPath("C:\Users\QaziWa\DownloadReportPPE.jar");
至
file.initWithPath("C:\Users\QaziWa\DownloadReportPPE.jar");
需要转义那些斜杠 ;)
我查看了此处已回答的以下问题:
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
然而 none 这些解决方案对我有用,我觉得问题可能比我原先想象的要深。本质上,我正在尝试启动一个带有 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) {
// try {
// var file = Services.dirsvc.get("Desk", Ci.nsIFile);
// file.append("C:\Users\QaziWa\DownloadReportPPE.jar");
// file.launch();
// }
// catch (ex) {
// console.error("failure");
// Failed to launch because e.g. the OS returned an error
// or the file does not exist,
// or this function is simply not implemented for a particular platform.
// }
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 文件没有被检测到,我不明白为什么。我希望有人可以提供任何意见,说明为什么会这样。
改变
file.initWithPath("C:\Users\QaziWa\DownloadReportPPE.jar");
至
file.initWithPath("C:\Users\QaziWa\DownloadReportPPE.jar");
需要转义那些斜杠 ;)