Create Firefox.msi & Thunderbird.msi with WiX

Config files and scripts to create MSI-files for Firefox and Thunderbird, almost completely automatic, within two minutes. Requires only tools which are completely free (no demo, fully free).

Note about Thunderbird: This page talks in many places only about Firefox, but config files are provided for both programs, and all descriptions apply to both. Just change the variable appname in the file init.bat to toggle between processing Firefox and Thunderbird.

Updates

2017-04-13: Firefox 52 triggers warning from light.exe
warning LGHT1076 : ICE60: The file filA8B8DD2ECDA7D0B88DF54B62F4BAC465 is not a Font, and its version is not a companion file reference. It should have a language specified in the Language column.
The filename is random. The referenced file is EmojiOneMozilla.ttf. It will nevertheless be included in the MSI-file and get installed in the fonts subdirectory.

2015-08-08: Project abandoned
I will probably not find time to finalize the port of this from Win-XP to Win-7 anytime soon.

2014-09-05: progress switching registry filter to whitelist
Finally: filter registry entries with whitelist instead of blacklist.
No surprises so far, but still testing, because better safe than sorry.
Next up: fix the last Win7 issues, then update this web page.

2014-07-25: Thunderbird 31
If you use this for Thunderbird 31, delete the file "Thunderbird userChrome.css" after extracting the zip file, and edit the file "Thunderbird mozilla.cfg": change the value of toolkit.telemetry.prompted from true to 2.
Also there appears to be yet another error in setting a wrong registry key in 64bit Win7 (probably harmless).

Warning: run these scripts in XP only (in a virtual machine):
This was developed and tested long ago in Windows-XP (32bit). The created MSI-files also work in Windows-7, both 32 and 64bit (only the registry-key TaskBarIDs will be missing). In theory the reverse should also be possible.
Starting with the version March 18th 2013 this should probably actually work, at least in 32-bit Windows-7.
However I must strongly recommend to not do it, because in one case I found a really nasty interaction between Mozillas Installer, the tool RegFromApp, and Windows-7, which can have serious consequences: It can cause additional registry keys to end up in the output of RegFromApp, and subsequently in the MSI-file. In one case it was the key
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer
Installing the resulting MSI-file appears to work fine first, but uninstalling it would remove a lot of registry entries that obviously should better not be removed!
This specific key is now filtered out in the current version, but I cannot rule out the possibility of more such surprises. Thus I plan to change the registry filter to use whitelisting instead of blacklisting. Meanwhile double-check the two reg-files to make sure nothing is in there that could cause problems upon install or uninstall.

Also Windows-7 64bit is probably too much different to fit well. Not only does the installer from Mozilla set many different registry keys there, it also leaves away an incompatible DLL (and all its registry keys). If you want MSI-files that work correctly in 64bit Windows-7, then you should create them in 64bit Windows-7. If you need MSI-files for both 32bit and 64bit, then you should create two different MSI-files. I have seen Firefox installed with MSI-files from Windows-XP work in Windows 7 64bit, but on inspection of the registry keys, I see many differences, and do not yet know if any of them are relevant for correct operation of some functions.

Features

Flexible: Works both with the normal rapid-release versions, and the esr versions. Tested with versions 10esr, 16, 17esr, 23, and 24 beta 9.

Reliable: This is not the wrapper-trick, and not one of the (often unreliable) before-after comparisons. It creates perfectly pure MSI-files, using the WiX toolset by Microsoft. All installation steps will be performed cleanly by Windows-Installer, there are no troublesome 'Custom Actions' involved.

Customizable: You can easily add config changes. My example disables the automatic updater and contains a few more suggestions. Just change this and/or add more. More info below.

One-Time Preparations

  • Select a PC (or virtual machine), on which Firefox is not installed, or where you can uninstall and later reinstall it. If it had been installed before, make sure that its program directory is empty, otherwise files left over there can end up in the MSI-file (alternatively you might want to use this as a feature, although I recommend to add such things to the scripts, see below).
  • If that PC is running Windows-XP: congratulations! Otherwise (Windows-Vista or Windows-7) make sure that the scripts will always run with full Administrator rights, otherwise UAC will block some required operations. If you run the scripts with right-click, run as admin, they will not work if they are on a shared folder.
  • Download and install WiX (I'm using version 3.5, haven't tested with later versions yet). WiX requires DotNet. WiX version 3.5 runs with the version of DotNet that is included in Win7.
  • Download and install 7zip with default settings.
  • Download RegFromApp (I have so far only used the 32bit version). Extract the exe file from the RegFromApp archive (for example using 7zip), and save it into the same directory as the contents of the zip archive.
    If your are using Windows-XP: congratulations! Otherwise (Windows-Vista or Windows-7): test RegFromApp. If it doesn't work, tell Windows to run it in XP compatibility mode (or do all in the virtual machine 'XP-mode' of Windows-7).
  • Create an empty directory somewhere, for example a directory named Mozilla-MSI on your desktop. Download one of the following zip archives, and extract its contents into this directory. The second variant auto-detects the new directory structure (with the subdirectory 'browser'), that was introduced with version 21. In theory the newer variant should also work with older versions of Firefox and Thunderbird, including 17, but I haven't tested this.
  • Edit the file init.bat: update the language ID (1033 for "English-United States", 1031 for "German-Germany", or click on the link for more examples). Also make sure that the variables in the sections directories and paths contain the correct path to the additionally required files. If you have done everything exactly as I suggested above, they should already be correct.
  • If your language is far away from English (using very different characters), maybe you also need to update Codepage in the file mozilla.wxs (the current value is 1252 for Latin 1 characters).

optional adjustments:

  • If you don't want Firefox to be declared as default browser for all users: remove the filename regkeys2.wixobj inside the file make msi.bat, and the whole line with the word regkeys2 from the file mozilla.wxs.
  • If you don't want to disable the import wizard of Firefox, remove the file Firefox override.ini
  • If you don't want to enable the main menu of Thunderbird, remove the file Thunderbird userChrome.css
  • Check all contents of the files mozilla.cfg and autoconfig.js. You will probably want to change or add some more settings. To find info about possible config changes look here, ask a web search engine for 'mozilla.cfg', read the blog of Mike Kaply, have a look at the CCK-wizard, and the addon gpo for firefox, Mozilla has also some info here.

Create an MSI-file

  1. Download the Installer.exe from Mozilla, and save it into the same directory as the contents of my zip archive, but don't run it.
  2. edit the file init.bat: update the version number, and optionally the variable esr, see the comments in the file. Leave esr empty for Thunderbird 24.
    The version number will end up in the file mozilla.wxs in two variables (name and version), and it's also used to make sure that the Product-ID and the GUID of the Shortcuts-Component are different for each version (here the number of digits is important).
    If you ever need to redistribute another variant of the same version, you should modify the contents of the variable vid4, to guarantee that the new file will get unique GUIDs.
  3. Run 'make all.bat' and wait until it says 'INSERT YOUR CUSTOMIZATIONS NOW'. At this time the script has already copied mozilla.cfg and autoconfig.js, but you might want to do more than that. Press any key when you have finished inserting your customizations (or modify 'make all.bat' to let it do the modifications for you).
  4. Now the script shows 'NOW RUN make msi.bat'. Do this!
  5. When the second process finishes, check if it shows *OK* or *ERROR*. Press any key to close that second window. Then press any key in the first window as well. Now this window should also show *OK*. Press another key to close this window.

If both scripts ended with *OK*, you should now have the MSI-file. The program, that was installed during this process, should have been automatically uninstalled after the last keypress.

More Info

The MSI-file tells windows installer to do four things: copy files, create shortcuts, define registry keys, and declare an icon for ARP.

  • The files are taken from the directory into which Firefox was installed.

  • Shortcuts are declared in the Startmenu, and on the Desktop for all users. If you don't like the desktop shortcut, edit the file 'mozilla.wxs' and remove that entry. This file is extremely difficult to set up, but the existing file is sufficiently self-explanatory to easily find the right place.

  • Collecting the registry settings works like this:
    The contents of the file Firefox-setup.exe are extracted with 7zip. This delivers most files that later end up in the program directory, plus a setup program in the file 'setup.exe'.
    The command 'setup.exe -ms' is run from within RegFromApp, and the created registry keys are saved in the file regkeys1.reg.
    Next the command 'helper.exe /SetAsDefaultAppGlobal' is run from within RegFromApp, and the created registry keys are saved in the file regkeys2.reg.
    These two reg files are cleaned of excess and problematic keys, and then converted to the required XML structure with the WiX tool 'heat.exe'. In these files the absolute paths containing %ProgramFiles% are replaced with a installer variable, that windows installer will later expand to whatever is the default path on the destination machine.

  • The icon for ARP was extracted from the executable with Icon Extractor. Please note that Mozilla does not permit to distribute custom created installers that use their original program name and/or icon, see their trademarks policy.

More on registry keys:

  • Capturing the registry keys written by helper.exe will work only when helper.exe is run for the first time. Consecutive executions of the same command will cause less registry keys from being written. Thus Firefox must be uninstalled and re-installed before running the capture again.

  • The tools strxchg.exe and clrregfile.exe were written by myself. They allow to automate the process of cleaning up the extracted registry keys. Source code is included (FreePascal) for both. The tool StrXchg (String Exchange) can replace every occurence of a text in a file with another text. ClrRegFile (Clear Registry-File) can remove single values or whole keys from a reg-file (if the registry file was saved in format version 4, or was at least converted to ansi encoding).

  • The removed registry keys are: CurrentVersion\Uninstall, FirefoxInstallerTest, Windows\CurrentVersion\Explorer, and everything in HKEY_CURRENT_USER (MountPoints2 and Shell Folders). Removing the uninstall key prevents a duplicate ARP-entry (windows-installer automatically adds one as well). FirefoxInstallerTest is only a temporary test key, the removal of which WiX doesn't understand. MountPoints2 and Shell Folders are not necessary, and they are set in HKCU, but the MSI is made to be installed per machine, thus this would trigger a warning from WiX.

FAQ

How to make these scripts run savely in Windows 7?
I plan to rewrite my registry cleanup tool to make it do whitelisting instead of blacklisting. Then potentially harmful registry keys cannot creep into the registry files, regardless of any more hickups that the RegFromApp tool might have in Windows 7.

Will you offer firefox.msi for download?
No, Mozilla does not allow this.

Do these MSI-files have disadvantages compared with using the original setup.exe?
Yes: uninstalling will not restore Internet Explorer as default browser. This is a shortcoming of Windows Installer: it removes registry entries, instead of restoring them to the previous state. Working around this would require to use a Custom Action, but I refuse to dig any further into WiX, especially regarding Custom Actions. You can put a shortcut to Internet Explorer on the desktop, the program will ask to make itself default when run. Also it would be easy to make an MSI-file that sets the required registry keys.

Do the MSI-files include the Mozilla Auto-Updater Service?
No. The files for this service are installed into a different directory, thus they are not collected. Also the registry keys for that service are set by a different setup program, so they are not collected either. I don't plan to ever include them, because if you deploy software, you should also deploy the updates yourself, and then any other automatic updater would only cause problems.

Why is the MSI-file bigger than the original installer by Mozilla?
Mozilla uses 7zip compression, whereas Windows installer uses an older and less efficient compression method.

Why the conversion from unicode to ansi and back to unicode?
heat.exe would garble umlaut characters like ä when reading files with ansi character encoding (like registry files in file format 4), but my tools StrXchg and ClrRegFile wouldn't work with unicode files (because FreePascal 2.6 doesn't support it, will be added in 2.8).

What is 'ARP'?
Short for 'Add- or Remove Programs', the control that comes up when you choose to remove software, can also be started by running the command 'appwiz.cpl'.

More Settings

  • Disable integrated pdf-viewer: pdfjs.disabled = 'true';

Also see mike.kaply.com/2012/03/16/customizing-firefox-autoconfig-files


last modifications:

  • 2017-06-14
    • scripts slightly updated
  • 2013-Oct-02
    • small updates to cfg-files (Firefox: disable pdf viewer & set default homepage, Thunderbird: show menu bar)
  • 2013-Aug-07
    • updated init.bat and make-all.bat to auto-detect the new 'browser' subdirectory, and to make it work when the version number in the filename of an esr-setup has only two parts like in 17.0 instead of 17.0.7
    • updated Firefox mozilla.cfg to disable plugins.notifyMissingFlash.
  • 2013-Apr-29
    • fix make-all.bat: more registry filtering (64bit Win7 uses 'explorer' instead of 'Explorer')
  • 2013-Mar-18
    • more fixes to hopefully make it work correctly in Windows 7 (most important: more registry filtering)
    • fix mozilla.wxs: make it work again with non-ESR versions.
    • upd init.bat: make it work with 64bit version of 7zip
    • upd make-all.bat: abort with error message if 7zip, RegFromApp, or WiX is missing.
    • chg make-all.bat: allow %appname%-specific files mozilla.cfg, override.ini, userChrome.css
    • chg make-all.bat: remove maintenanceservice.exe.
    • add Firefox override.ini: disable import wizard
    • add Thunderbird userChrome.css: re-enable main menu
    • removed choice between two variants, because variant one had too many disadvantages.
  • 2013-Jan-16
    • more adjustments to make it create univerally working MSI-files, when creating them in 64bit Windows-7
    • registry files for variant 1 now contain version number 17.0.2esr and texts in english(US)
  • 2013-Jan-10
    • Thunderbird support integrated
    • tested with version 17esr
    • bugfixes, improvements
    • some adjustments to make it run in 64bit Windows-7
  • 2012-Nov-19
    • got RegFromApp to run in Windows 7.
    • moved info about RegFromApp to separate page.
  • 2012-Nov-12
    • added more "quotes" in script for cases when path contains blanks
    • tested with Windows 7: on my PC the tool RegFromApp doesn't work in Windows 7
  • 2012-Nov-05
    • scripts slightly enhanced
    • text improved, typos fixed
  • 2012-Nov-04
    • fix StrXchg: did cut long lines
    • solved umlaut-problem, removing less registry entries
  • 2012-Nov-02
    • added Firefox.ico to make msi-file 900 kb smaller
    • removed duplicate uninstall entry
    • added entry CheckDefaultBrowser to mozilla.cfg. This prevents the errorneous question about making Firefox 14ff the default browser, even if it already is default for all users (see bug 780118).
    • separate %vid% added in init.bat for use of version numbers in GUIDs, because the number of digits of a GUIDs must not change when a version number rolls from single-digit to two-digit.
  • 2012-Nov-01: first version ready, scripts pass basic test
  • 2012-Oct-24: solution found, web page started