javascriptinstallationxulxulrunner

How to get the installation path of a XULRunner application in JavaScript code


Assume we have a XULRunner application installed at C:\myapp\, that is, application.ini file etc. are in that directory. My question is: how to get the installation path (C:\myapp\) in the app's JavaScript code?


Solution

  • I think that for XULrunner, CurProcD is usually the installation path:

    var path = Components.classes["@mozilla.org/file/directory_service;1"]
                 .getService(Components.interfaces.nsIProperties)
                 .get("CurProcD", Components.interfaces.nsIFile).path;
    

    Failing that, you might also try resource:app.

    Ref: File I/O at MDN.