How to run an external application using the Firefox add-on?

I am trying to execute a .exe file using nsIProcess. But it does not work and does not give any error message. I am working on firefox 10 and windows 7. Can anyone suggest me a 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(); 
+5
source share
1 answer

You forgot one backslash before MJ:

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

So your application is not running because it is not found. However, the best way to run applications is usually nsIProcess - it allows you to specify command line options, and also provides 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);
+10
source

All Articles