Q:

using firefox to launch an external program found in the system PATH

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);
}

A:

nsIProcess won't do this, it only accepts full paths. You will need to take a look at environment variables yourself:
var environment = Components.classes["@mozilla.org/process/environment;1"]
                            .getService(Components.interfaces.nsIEnvironment);
var path = environment.get("PATH");
var root = environment.get("SYSTEMROOT");

You can either split up the PATH variable and check the various directories or use the value of the SYSTEMROOT variable.
You could run cmd.exe /c notepad.exe but there you also need to locate cmd.exe first.

