Install Object

Parts of this page show the use of the XPInstall API. The majority of this API is now deprecated and as of Gecko 1.9 no longer available. Extension, Theme, and plug-in developers must switch away from install.js based packages to the new packaging scheme with an install.rdf manifest. In particular plugin developers should see how to package a plugin as an extension.

Install

Use the Install object to manage the downloading and installation of software with the XPI Installation Manager.

Overview

The Install object is used primarily in installation scripts. In all cases, the Install object is implicit--like the window object in regular web page scripts--and needn't be prefixed to the object methods. The following two lines, for example, are equivalent:

f = getFolder("Program");
f = Install.getFolder("Program");

An installation script is composed of calls to the Install object, and generally takes the following form:

Initialize the installation
Call initInstall with the name of the installation and the necessary registry and version information.
Add the files to the installation
Add files to the installation by calling getFolder to get file objects and passing those object refs to addFile as many times as necessary.
Perform installation
Check that the files have been added successfully (e.g., by checking the error Return Codes from many of the main installation methods, and go ahead with the install if everything is in order:
performOrCancel();
function performOrCancel()
{
  if (0 == getLastError())
     performInstall();        
   else
     cancelInstall();
}

For complete script examples, see Script Examples.

Document Tags and Contributors

 Contributors to this page: Sheppy, trevorh, Nickolay, Fredchat, Whitewitch, Callek, Zhangsy, Rod Whiteley
 Last updated by: Sheppy,