Launching an application with XPCOM

Continuing to document my work with XULRunner, XUL, and XPCOM, here I’m presenting code on how to launch an executable using XPCOM’s nsILocalFile interface fetch the executable file and the nsIProcess interface to execute the process.

// target = path to executable
// args = arguments for executable
function exec(target, args) {

try {

var file = Components.classes[";1"].createInstance(Components.interfaces.nsILocalFile);

var process = Components.classes[";1"].createInstance(Components.interfaces.nsIProcess);

var args = [''];
false, args, args.length);
return process;
catch (err) {
return null;