This is an archived page. It's not actively maintained.


The Profile Service manages user profiles.
Inherits from: nsISupports Last changed in Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0)

Note: Starting in Gecko 1.9.1, this service is implemented by;1. To access the service, you can use the following code:

var toolkitProfileService = Components.classes[";1"]

Prior to Gecko 1.9.1 only the built-in profile manager was able to access the toolkit profile service. To access the built-in profile manager in versions of Firefox up to 4.0 and Thunderbird up to 3.3 you can launch with the -profilemanager command line flag. Future versions will require the separate Profile Manager application.

Warning: This service is synchronous so it is recommended that you use OS.File to find the profile directory via OS.Constants.Path.profileDir. OS.File is available from Gecko 18 (Firefox 18.0 / Thunderbird 18.0 / SeaMonkey 2.15).



Method overview

nsIToolkitProfile createProfile(in nsILocalFile aRootDir, in AUTF8String aName);
void flush();
nsIToolkitProfile getProfileByName(in AUTF8String aName);
nsIProfileLock lockProfilePath(in nsILocalFile aDirectory, in nsILocalFile aTempDirectory);


Attribute Type Description
profileCount unsigned long The number of user profiles currently in existence. This will always return 0, 1, or 2; if there are more than 2 profiles, 2 is always returned. Read only.
profiles nsISimpleEnumerator An enumerator providing access to the list of profiles; each profile is an nsIToolkitProfile object (though you must first call aProfile.QueryInterface(Components.interfaces.nsIToolkitProfile) to get access to its attributes and methods).
selectedProfile nsIToolkitProfile The profile that is marked as "Default=1" in the Profiles.ini file. (NOT the profile currently in use.) Not sure what happens if you change this setting but someone said: You can change profiles by setting this attribute's value. This may throw an NS_ERROR_FAILURE (0x80004005) when trying to get the current profile if it's unavailable or if permissions restrict access.
startOffline boolean
startWithLastProfile boolean  



Creates a new profile.

The profile temporary directory will be chosen based on where the profile directory is located.

nsIToolkitProfile createProfile(
  in nsILocalFile aRootDir,
  in AUTF8String aName
The profile directory. May be null, in which case a suitable default will be chosen based on the profile name.
The name to give the new profile.
Return value

An nsIToolkitProfile object representing the newly-created profile.

Exceptions thrown
An unexpected error condition occurred.
One of the specified directory files is not actually a directory.
Unable to allocate the new profile object.


Flushes the profile list to disk.

The profile list file is constructed in memory, then written out as one large chunk, in order to reduce the risk of the profile list file being corrupted by disk errors.

void flush();


Exceptions thrown
An error occurred trying to allocate the memory buffer used to construct the profile list.
An error occurred writing the profile list file to disk.


Gets a profile, given the profile's name.

nsIToolkitProfile getProfileByName(
  in AUTF8String aName
The profile name to find.
Return value

An nsIToolkitProfile object describing the specified profile.

Exceptions thrown
No matching profile was found.


Locks an arbitrary path as a profile. If the path does not exist, it is created and the defaults copied from the application directory.

nsIProfileLock lockProfilePath(
  in nsILocalFile aDirectory,
  in nsILocalFile aTempDirectory
The directory to lock as a profile directory.
The directory to lock as a profile temporary directory.
Return value

An nsIProfileLock object representing the locked directory.

See also