Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to execute an external application using firefox addon?

I try to execute .exe file using nsIProcess. But it is not working and not giving any error message. I am working on firefox 10 and windows 7. Can anybody suggest me any solution? Thanks

var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsIProcess);
file.initWithPath("C:\\Users\MJ\\Desktop\\Example.FaceDetection.exe");  
file.launch(); 
like image 729
Mangala Edirisinghe Avatar asked Jul 17 '12 16:07

Mangala Edirisinghe


People also ask

Is there a Task Manager for Firefox?

Firefox's Task Manager feature lets you see which tabs or extensions are using a lot of memory or energy. This feature can be useful when diagnosing high CPU or memory usage in Firefox.

How do I access apps in Firefox?

Open Firefox. In the window's upper-right corner, click the Open Applications Menu  icon.


1 Answers

You forgot one backslash before MJ:

file.initWithPath("C:\\Users\\MJ\\Desktop\\Example.FaceDetection.exe");

So your application doesn't execute because it isn't being found. That said, the better way to run applications is usually nsIProcess - it allows you to specify command line parameters and it will also provide useful feedback:

var params = ["foo", "bar"];
var process = Components.classes["@mozilla.org/process/util;1"]
                        .createInstance(Components.interfaces.nsIProcess);
process.init(file);
process.run(false, params, params.length);
like image 77
Wladimir Palant Avatar answered Sep 20 '22 23:09

Wladimir Palant