Thursday, March 17, 2016

Firefox setting for all users - Deployment guide

Firefox is one of the most versatile browsers out there as far as being able to customize the settings for it, its huge selection of addons and its ability to shine where where other browsers like Internet Explorer and Chrome might not be as forgiving when it comes to displaying web pages.

This post is mainly going to show you in easy steps how to deploy Firefox on a machine and have global settings adjusted for all users. I will have several examples that solve annoyances that many users have experienced.

Once the configuration files are in place any new user and or Mozilla Firefox profiles that are created from that point forward will adhere to certain predefined guidelines. Also any already existing profiles will not be effected by the change.

The Download of a pre-configured file is at the bottom of this blog, there is a list of setting that are explicitly set as well.

Lets get right to it!

A couple of prerequisites to assist you in the endeavor:

1) You must be an administrator on the machine
2) Enabling file extensions is a must for this project
3) Showing hidden files and protected operating system files is helpful
4) Download Notepad++ is once again very helpful as a text editor but not required.

First lets make a New Folder somewhere for this project to keep things easy to find. We will call this your 'working folder'. Once you do that you will need to create two files with non popular files extensions.

1) Mozilla.cfg
2) local-settings.js

To make these files, open your working folder, right click and choose new, then new text file. Once one new text files is created make sure it looks something like this: New Text Document.txt. Notice the files extension '.txt' shows. Right click and choose 'rename' then change it to 'local-settings.js'. Then create another text file and do the same renaming it to 'Mozilla.cfg'.

Once you have those two files right click on them and choose edit with Notepad++. You will now be able to easily edit these files in the future if you need to make any changes. Lets start with the first file we created. The 'local-settings.js'. Right click, edit with Notepad++ or your preferred text editor.

This file is going to be a static file, and will contain only two lines. These two lines will tell Firefox that we will be using custom settings. The contents of this file is:

pref("general.config.obscure_value", 0);
pref("general.config.filename", "mozilla.cfg");

These basically tell Firefox to look for a file called 'Mozilla.cfg', and to use the setting within that file to set your choice of global setting for all users going forward on a particular machine.

The 'local-settings.js' file will be placed in the following location; of which depend on if you use the true 64 bit version of Firefox or the standard 32 bit version of Firefox. Those locations are as follows:

32 bit FireFox:
C:\Program Files (x86)\Mozilla Firefox\defaults\pref\local-settings.js

64 bit FireFox:
C:\Program Files\Mozilla Firefox\defaults\pref\local-settings.js

Next lets move on to where the magic happens which is the 'Mozilla.cfg' file. Lets edit this file now and I will show you several examples of settings that can help improve a first time users experience with Mozilla Firefox. First off the first line of the file must only contain '//'. Any additions lines containing those two '//' will be used for comment purposes only which means that they will not be read as configurations in Mozilla Firefox. Below is an example of a 'Mozilla.cfg' file with some settings designed to provide a positive experience removing any annoyances as of this writing.

//
//sets Google as the default search engine instead of Yahoo
pref("browser.search.geoSpecificDefaults", false); 
pref("browser.search.defaultenginename.US", "data:text/plain,browser.search.defaultenginename.US=Google");

// set FireFox Default homepage 

defaultPref("browser.startup.homepage", "data:text/plain,browser.startup.homepage=https://startpage.com");

// Don't show Whats New on first run after every update

pref("browser.startup.homepage_override.mstone","ignore");

// disables the 'know your rights' button from displaying on first run

pref("browser.rights.3.shown", true);
pref("browser.usedOnWindows10", true);

//disable default browser check

pref("browser.shell.checkDefaultBrowser", false);

// set all plugins to always activated

pref("plugin.default.state", 2);

// hide choose what i share that pops up at the bottom of the browser after the first minute

lockPref("datareporting.policy.dataSubmissionPolicyBypassNotification", true);

// disables the request to send performance data from displaying 

pref("toolkit.telemetry.prompted", 2); 
pref("toolkit.telemetry.rejected", true);

// do not block popups - can only be default or locked pref
defaultPref("dom.disable_open_during_load", false);

// prevent reader view from popping down

pref("reader.parse-on-load.enabled",false);


// The next 3 lines shows you how to clear all browsing data/history upon close

//lockpref("privacy.sanitize.migrateFx3Prefs", true);
//lockpref("privacy.sanitize.promptOnSanitize", false);
//lockpref("privacy.sanitize.sanitizeOnShutdown", true);
// http://www.pcc-services.com/kixtart/firefox-lockdown.html
// This last line allows your browser to operate exclusively in Private Browsing Mode
//pref("browser.privatebrowsing.autostart", true);


This file will go into the following location depending on if you are 32 bit or 64 bit:

32 bit FireFox:
C:\Program Files (x86)\Mozilla Firefox\mozilla.cfg

64 bit FireFox:
C:\Program Files\Mozilla Firefox\mozilla.cfg

It is important to note here some of the settings and what they mean. We see things like 'defaultpref' lets go over them.

pref
    sets the preference as if a user had set it, every time you start the browser. So users can make changes, but they will be erased on restart. If you set a particular preference this way, it shows up in about:config as "user set". 

defaultPref
    is used to alter the default value, though users can set it normally and their changes will be saved between sessions. If preferences are reset to default through the GUI or some other method, this is what they will go back to. Appears in about:config as "default". 

lockPref
    is used to lock preferences so they cannot be changed through the GUI or about:config. In many cases the GUI will change to reflect this, graying out or removing options. Appears in about:config as "locked". Some config items require lockPref to be set, such as app.update.enabled. It will not work if it set with just pref.

clearPref
    can be used to "blank" certain preferences. This can be useful e.g. to disable functions that rely on comparing version numbers. 

It is important that not all of these prefixes can be used with every single setting. If FireFox does not launch when deploying other custom settings it is likely a bad prefix so it is a good idea to add and test you setting one by one to make sure they take. and do not cause FireFox to not start. 

A good resource is here:
http://www.pcc-services.com/kixtart/firefox-lockdown.html

Other settings you might have to hunt for. If you are familiar with 'about:config' you should know that a lot of those setting can be used in the 'Mozilla.cfg' file, but not all

Another good file to have is the 'override.ini' This file will eliminate the import wizard. More information on that is located below as well as some of what we already went over:
http://www.itninja.com/question/firefox-18-deployment-issues-config-problems

When Uninstalling Firefox, it is important to remove the files that you created and placed otherwise after the uninstall of Firefox will request a reboot to finish removing the files.

FireFox Auto download/clean install of FireFox and set up of default setting for all users


I have created two exe files that will do the following:
1) Uninstall the current version of Firefox ( either 64 bit or 32 bit whichever your choose. I recommend that IF you are on a 64 bit Windows system you use the 64 bit build instead of the 32 bit one as it is more stable and performs better ).
2) Remove any of the above mentioned files as above to allow for default setting for all users.
3) Grab the latest version of Firefox from the official Firefox Website and install it, and set setting for all users files.
4) Delete the Installer file.

There are 3 files for your viewing pleasure.

1) 64 bit beta version ( will not uninstall 32 bit versions )
2) 32 bit stable version
3) An example of the mozilla.cfg file being used if there is not one chosen ( below )

Theses installs will NOT delete any bookmarks, favorites, preferences, etc.

The mozilla cfg file is embedded in the exe with some default setting to allow you to see what setting are being used and how to do it.

IF you choose to and want to use your own configuration file, you can modify my example or you can build you own and simply place it in the same directory as the exe file is.. It is that simple.

Some of the setting I have found that works good and reduces frustration for user are:

1) set Google as the default search engine ( I simply HATE YAHOO as a search, too much spam and ads ).
2) Uses https://startpage.com as home page ( secure search engine that does not track ).
3) Don't show Whats New on first run after every update.
4) Disables the 'know your rights' button from displaying on first run.
5) Do not ask or check if Firefox is default browser.
6) Set all plugins to always activated.
7) Hide choose what i share from popping up at the bottom after about a minute.
8) Do not block popups.
9) Prevent reader view displaying on a page for the first time.
10) Set do not track.
11) Clears the cache ONLY When Firefox closes ( helps prevent cache files from creating issues and keeps clutter down on your system )
12) Disable Firefox's refresh notification. see the following articles:
http://techdows.com/2016/05/firefox-reinstall-to-prompt-for-a-refresh.html
https://support.mozilla.org/en-US/questions/1084402

As always you can create your own custom files, modify my setting and activate other setting by simply removing the // at the beginning of the lines.

If Firefox does not start after changing setting it is most likely one of the setting is set wrong or in conflict with another.

Here is the Download location for the project


August 10 2016 changes:

1) Structured code(x64)
2) Changed the way I looked for and deleted previous config files(x64)
3) Minor text changes(x64)
4) Added the following line to the cfg file(x64): pref("browser.disableResetPrompt", true);

12 comments:

  1. Thanks for the info. The only issue that I am having with this is that in order for any of the changes to take place, I have to "Refresh" Firefox everytime. How do I set it to where The change just take effect on browser restart?

    ReplyDelete
    Replies
    1. I am not sure if you are in an cooperate environment or not however, I am attempting to get our person that does the imaging to use this method as they use another method which in a nutshell has a premade profile placed in c:\users\default\appdata\local and c:\users\default\appdata\roaming that then gets transferred to every single user that logs into the machine regardless if they use it or not.

      This method creates additional bulk data and adds to profile create/login times. It is not recommended, however, if in a work environment it is possible it is there as someone is old school still and you would have to delete the Mozilla folders there. Furthermore, you will need to delete the same data on a per user profile basis to fully take effect. Mind you this will delete all bookmarks. I do have something that will delete all Mozilla data from all profiles if you need it.

      There are some settings that will override what is currently used for the current profile if you do not delete the current profile, however I do not know which setting get overridden as i have not made a list.

      Delete
    2. Thanks for the quick reply Carmine. I am in a work environment trying to get this item to work for all PCs. Everything except the search engine and attachments that I have in the cfg file works when I close out and open Firefox:


      //
      // Don't show the Firefox has been upgraded page
      lockPref("browser.startup.homepage_override.mstone", "ignore");

      // Don't check for the default browser
      lockPref("browser.shell.checkDefaultBrowser", false);

      // Disable automatic updates
      lockPref("app.update.enabled", false);

      // Do not send stats
      lockPref("toolkit.telemetry.enabled", false);
      lockPref("toolkit.telemetry.rejected", true);
      lockPref("toolkit.telemetry.prompted", 2);

      // Hide Know your rights
      lockPref("browser.rights.3.shown", true);

      // set all plugins to always activated
      pref("plugin.default.state", 2);

      // enable extensions?
      lockPref("extensions.autoDisableScopes", 0);

      // Default Search Engine - Mailto
      lockPref("browser.search.isUS", false);
      lockPref("browser.search.geoSpecificDefaults", false);
      lockPref("browser.search.defaultenginename.US", "data:text/plain,browser.search.defaultenginename.US.1=Google");
      lockPref("browser.search.order.1", "Google");
      lockPref("browser.search.order.2", "Google");
      lockPref("browser.search.order.US.1", "data:text/plain,browser.search.defaultenginename.US=Google");
      lockPref("browser.contentHandlers.types.0.title", "Google");
      lockPref("browser.order.US.1", "data:text/plain,browser.search.order.US.1=Google");
      lockPref("gecko.handlerService.schemes.mailto.0.name", "GMail");
      lockPref("gecko.handlerService.schemes.mailto.0.uriTemplate", "https://mail.google.com/mail/u/0/#compose");

      Refreshing Firefox has the same effect of removing bookmarks and additional information that I would like to keep intact.

      Delete
    3. Sorry. Not attachments, extensions. Search Engine and Extensions do not work unless I refresh firefox

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. The search engine is a user setting and was set by the current user and if memory serves me correct i tested that and will not override if set to pref. Also please note that some settings cannot use things such as lockpref, pref or defaultPref might not be interchangeable with all settings. There is no rime or reason given that I know of. Sometimes you just have to tinker. FYI.

    Just don't forget any default profile under what I mentioned b/c that could bork thinks up if they are not removed from default user profile.

    ReplyDelete
  4. Right... So it's functioning as intended. Thanks for the insight. Very informative!!!

    ReplyDelete
  5. Thanks for the post and great tips: even I also think that hard work is the most important aspect of getting success. Search Bar Firefox 57 Quantum addon

    ReplyDelete

  6. Hi guys,
    Thank you so much for this wonderful article really!
    If someone want to know more about the Firefox extension I think this is the right place for you!

    ReplyDelete
  7. Hello!
    Really useful article indeed.

    I am now struggling to configure Firefox in a VDI environment and we want the Firefox profiles to be stored on a network share in order to take them out from the user folder.

    Would you be able to provide me any help with it? I guess there should be a line in the mozilla.cfg file to change the path, but I'm not able to find it.

    ReplyDelete
    Replies
    1. http://kb.mozillazine.org/Thunderbird_:_FAQs_:_Changing_Profile_Folder_Location

      look under advanced. I never done this before, so hope it helps

      Delete
    2. Thanks for the tip.

      I came accross that website already. That works but just for 1 user. If another user logs in the computer, his profile will go to appdata.

      That's why I guess it should be some config file in the install folder...

      Thanks anyway!!!

      Delete