i have an addon that i want to use to start program already installed on my computer eg notepad.exe
The problem is that it seems firefox does not search the system PATH for the program ie
file.initWithPath("c:\\windows\\system32\\notepad.exe");//works
//file.initWithPath("notepad.exe");//does not work
//file.initWithPath("%systemroot%\\notepad.exe");//does not work
Question:
Is there a way of making firefox look for programs in the system PATH?
Here is my complete function
autoStartNotepad:function()
{
// create an nsILocalFile for the executable
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("notepad.exe");//does not work
//but file.initWithPath("c:\\windows\\system32\\notepad.exe");//works
// create an nsIProcess
var process = Components.classes["@mozilla.org/process/util;1"]
.createInstance(Components.interfaces.nsIProcess);
process.init(file);
// Run the process.
// If first param is true, calling thread will be blocked until
// called process terminates.
// Second and third params are used to pass command-line arguments
// to the process.
var args = [];
process.run(false, args, args.length);
}
nsIProcesswon’t do this, it only accepts full paths. You will need to take a look at environment variables yourself:You can either split up the
PATHvariable and check the various directories or use the value of theSYSTEMROOTvariable.You could run
cmd.exe /c notepad.exebut there you also need to locatecmd.exefirst.