252 Part V — Installation, Automation, Tools, and Tricks To download Shockwave just visit and download the installer using Firefox: http://sdc .shockwave.com/shockwave/download/download.cgi? . Both installers have the ability to run in silent mode by specifying a command-line parameter of /silent, as shown for the Flash Installer: flashplayer7installer.exe /silent The only major problem is that the new Shockwave installer now also includes the Yahoo! Toolbar installation, and this will be automatically installed if you run the Shockwave installer with the command-line /silent parameter. Unless you have or want to use the Yahoo! Toolbar, the silent option will not work. An alternative approach to silent installation is to sign up for the Macromedia Distribution Program. The distribution program, found at http:// www.macromedia.com/support/shockwave/info/licensing/ , gives you one installer for both Flash and Shockwave that can also be executed with the /silent parameter. Installation is a breeze; during the installation, an installer tray icon and the Shockwave extrac- tion screen are visible, but the whole process is automated and works well to add Flash and Shockwave support to Firefox. After you fill out the registration form for the distribution program, a download link is sent via e-mail. Once the installer has been downloaded, it can be run in silent mode with the following: mm_fl_sw_installer.exe /silent Adding Apple QuickTime and RealPlayer Support Both QuickTime and RealPlayer come with components and plugin files that allow Firefox to offer embedded playback of these media file types. The newer QuickTime and RealPlayer installers automatically detect and copy the corresponding components and plugins if Firefox is already installed. Unfortunately, if Firefox is installed after these media tools, it will not have, nor will it be able to find, the plugins and components needed to allow them to work properly. So you can either reinstall both media tools after installing Firefox or just copy the contents of the components and plugins directories associated with QuickTime and RealPlayer to the cor- responding directories in the main Firefox application directory. The default Firefox path would be something like this: Ⅲ C:\Program Files\Mozilla Firefox\plugins Ⅲ C:\Program Files\Mozilla Firefox\components The default path for RealPlayer browser plugin and component files is C:\Program Files\ Real\RealPlayer\Netscape6. The default path for Apple QuickTime is C:\Program Files\Apple\QuickTime\Plugins. Creating a script to automatically copy these over will always ensure that the plugins and com- ponents match the installed versions of QuickTime or RealPlayer. 20_596500 ch13.qxd 6/30/05 3:06 PM Page 252 253 Chapter 13 — Hacking Installation and Deployment Create a Custom Windows Desktop Icon In a great posting on his site, Henrik Gemal has created Microsoft Windows Scripts to auto- mate the creation of Windows desktop icons for Firefox, Thunderbird, and Sunbird. The dif- ference between a desktop icon and a standard shortcut icon is that it implements Microsoft’s namespace functionality to give the desktop icon enhanced right-click functionality, much like Microsoft Outlook and Internet Explorer. Figure 13-3 shows the key right-click context menu options available: Open, Open (Safe Mode), Options, and Profile Manager. For more information on the status of integrating this feature into the official Firefox installer, visit the following Bugzilla posting: https://bugzilla.mozilla.org/show_bug .cgi?id=264889. F IGURE 13-3: Right-click menu for Firefox desktop icon To use this, just download and execute the Microsoft script file from http://gemal.dk/ misc/desktop-firefox.vbs , and a desktop icon will be created. Just remove the old Mozilla Firefox shortcut before running the script. You may have to refresh your desktop by switching focus to the desktop and pressing F5 or by logging off and then back on. For more information on the desktop links from Henrik’s site, visit http://gemal.dk/ blog/2004/11/05/firefox_thunderbird_and_sunbird_desktop_shortcuts/. This script is also a good reference point to use if you want to extract the necessary registry information to create your own script to accomplish the same thing. Hacking the Desktop Icon with Nullsoft Installer Script Tapping into Henrik’s script, I have converted it to a Nullsoft Installer script that you can com- pile with the Nullsoft Scriptable Install System (NSIS) installer engine. To download the NSIS visit its site at http://nsis.sourceforge.net/. 20_596500 ch13.qxd 6/30/05 3:06 PM Page 253 254 Part V — Installation, Automation, Tools, and Tricks The script is designed to do the following: Ⅲ Remove previous registry entries. Ⅲ Add the appropriate registry entries for the desktop icon. Ⅲ Remove the standard Mozilla Firefox shortcut link from the desktop. Ⅲ Refresh the desktop to force the display of the newly created icon. The script will automatically run in silent mode with no dialog windows and is available for download at http://www.hackingfirefox.com/desktop-icon.nsi. For easier editing and compiling, I like to use HM NIS Editor, an open-source editing tool for NSIS scripts. This editor includes a great Help file and syntax highlighting for all the NSIS keywords, functions, and commands. Figure 13-4 displays the desktop-icon.nsi script using the HM NIS Editor. F IGURE 13-4: HM NIS Editor with desktop-icon.nsi script loaded Following is a full listing of the desktop-icon.nsi source code: ############################################################### # Hacking Firefox: Desktop Icon - version 1.0 ############################################################### 20_596500 ch13.qxd 6/30/05 3:06 PM Page 254 255 Chapter 13 — Hacking Installation and Deployment # Define Variables !define PROD_NAME “Mozilla Firefox” !define PROD_PREF “chrome://browser/content/pref/pref.xul” !define TOOL_TIP “${PROD_NAME} - Rediscover the web” !define PROD_GUID “{EC8030F7-C20A-464F-9B0E-13A3A9E97384}” !define PROD_CLSID “CLSID\${PROD_GUID}” var PROD_EXE SetCompressor LZMA SilentInstall Silent OutFile “desktop-icon.exe” Section “Create Icons” section01 # Remove old icon settings DeleteRegKey HKCR “${PROD_CLSID}” # Get Current Path and Executable ReadRegStr $0 HKLM “SOFTWARE\Mozilla\${PROD_NAME}” “CurrentVersion” ReadRegStr $PROD_EXE HKLM “SOFTWARE\Mozilla\${PROD_NAME}\$0\Main” “PathToExe” # Setup NameSpace Icon WriteRegStr HKCR “${PROD_CLSID}” “” “${PROD_NAME}” WriteRegExpandStr HKCR “${PROD_CLSID}” “InfoTip” “${TOOL_TIP}” WriteRegStr HKCR “${PROD_CLSID}\DefaultIcon” “” “$PROD_EXE,0” WriteRegStr HKCR “${PROD_CLSID}\Shell\Open” “” “&Open” WriteRegStr HKCR “${PROD_CLSID}\Shell\Open\command” “” “$PROD_EXE” WriteRegStr HKCR “${PROD_CLSID}\Shell\Open (safe-mode)” “” “Open (&Safe Mode)” WriteRegStr HKCR “${PROD_CLSID}\Shell\Open (safe-mode)\Command” “” “$PROD_EXE -safe-mode” WriteRegStr HKCR “${PROD_CLSID}\Shell\Options” “” “Op&tions” WriteRegStr HKCR “${PROD_CLSID}\Shell\Options\Command” “” “$PROD_EXE -chrome ${PROD_PREF}” WriteRegStr HKCR “${PROD_CLSID}\Shell\Profilemanager” “” “&Profile Manager” WriteRegStr HKCR “${PROD_CLSID}\Shell\Profilemanager\Command” “” “$PROD_EXE -ProfileManager” 20_596500 ch13.qxd 6/30/05 3:06 PM Page 255 256 Part V — Installation, Automation, Tools, and Tricks WriteRegBin HKCR “${PROD_CLSID}\ShellFolder” “Attributes” 32000000 WriteRegStr HKCR “${PROD_CLSID}\ShellFolder” “HideOnDesktopPerUser” “” # Show Icons WriteRegDWORD HKCU “SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIco ns\NewStartPanel” “${PROD_GUID}” “0” WriteRegDWORD HKCU “SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIco ns\ClassicStartMenu” “${PROD_GUID}” “0” # Create NameSpace Icon WriteRegStr HKLM “SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSp ace\${PROD_GUID}” “” “${PROD_NAME}” # Remove Old Shortcut Delete “$DESKTOP\Mozilla Firefox.lnk” SetShellVarContext all Delete “$DESKTOP\Mozilla Firefox.lnk” # Refresh Desktop to show newly created desktop icon System::Call ‘user32.dll::RedrawWindow(i 0, i 0, i 0, i 0x0085) i .r1’ SectionEnd Other Notable Deploy Tools Currently, there is only one initiative to create a deployable and customized Firefox installation for Windows, and that is FFDeploy. The tool itself is just a combination of Windows Scripts and other small executables, but the effort to automate this is not trivial, and kudos go out to Bob Templeton for his hard work. To get more information on FFDeploy, just visit http://home.comcast.net/~ifrit/ FFDeploy.html. Creating a Custom Installer One issue I want to discuss without going too deeply into its logistics and semantics is the options available with different tools to create a custom Windows installer. The system used for deployment will determine what approach to take. Active Directory, ZENworks, and other sys- tems have built-in mechanisms for detecting which versions and packages are installed and come with different options. While an entire book could be written on how to deploy Firefox with all these systems, the following sections focus on highlighting tools that you could use with these systems, including some short sample scripts to help with the automation process. 20_596500 ch13.qxd 6/30/05 3:06 PM Page 256 257 Chapter 13 — Hacking Installation and Deployment Custom Nullsoft Scriptable Install System Installer The Nullsoft Scriptable Install System is a great scripting tool that I like to use to create full installers, as well as customized scripting executables that run silently. It supports all the key areas with file management, and registry and other great functions. Another great feature of this tool is that it supports LZMA, ZLIB, and BZIP2 compression of files that are included with the installers that it will create; and the NSIS installer itself adds minimal overhead to the size of the installer created. To download the core NSIS installer tool, visit http://nsis .sourceforge.net/ . After installing the main NSIS engine tool, files with .nsi extensions get two right-click con- text menu options, Complete NSIS Script and Complete NSIS Script (Choose Compressor). Either can be used to quickly create an installer from an existing NSIS script file. All NSIS scripts are text-based and can be edited with any standard text editor. To gain better control over editing and to get color syntax highlighting of NSIS keywords and functions (as shown in Figure 13-4), I like to use the HM NIS Edit tool, which can be downloaded from http:// hmne.sourceforge.net/ . This free editor is a great companion to the NSIS engine and provides a nice interface to editing and compiling your source NSIS scripts. Knowing that I could modify the config.ini from the extracted installer, I wanted to write a script that would automate specific config.ini settings that I wanted to create; this script would make future upgrades easier to deploy. The script that follows focuses on providing methods for modifying the run mode; updating the installation path; disabling specific dialogs (if running in normal versus silent mode); and providing a mechanism to create a full installer, versus a stub installer, that would run the setup from the extracted directory. To download this NSIS script example, visit http://www.hackingfirefox.com/custom-installer.nsi. This script relies on the fact that the Firefox installer is extracted to a directory, as highlighted earlier in this chapter. To specify the path that the Firefox installer is extracted to, start by look- ing for the following line of code: !define SOURCE_PATH “setup” This current line looks for the config.ini and Firefox setup files in a subdirectory of setup. The setup path is a relative directory to the current location where the NSIS script is running from. To specify a different directory, just change this value, as in the following example: !define SOURCE_PATH “d:\Firefox Extracted Files” The value for SOURCE_PATH has to be a directory and does not have to have a trailing slash. All files in this directory will be included with the full installer. Trying to make the script as generic as possible, I have included sections of code that are com- mented out with semicolons, which can be used to further customize the script. To run the installer in normal mode and disable specific dialogs, change the Run Mode value of Silent to Normal, as follows: 20_596500 ch13.qxd 6/30/05 3:06 PM Page 257 258 Part V — Installation, Automation, Tools, and Tricks WriteINIStr “${SOURCE_PATH}\config.ini” “General” “Run Mode” “Normal” Then add the dialog window registry edits that you want to disable. For example, to disable the welcome dialog, uncomment this line: WriteINIStr “${SOURCE_PATH}\config.ini” “Dialog Welcome” “Show Dialog” “FALSE” Other installer dialogs include the following: Ⅲ Dialog Welcome Ⅲ Dialog License Ⅲ Dialog Setup Type Ⅲ Dialog Select Components Ⅲ Dialog Select Install Path Ⅲ Dialog Install Successful Another option I wanted to add was the ability to create a full installer and a stub installer. The full installer would repackage the customized config.ini with all the original Firefox installation files, and the stub installer would just have the config.ini changes and would execute the installer from the directory it was extracted to. The base script is designed to create a full installer. To modify it to create a stub installer, just switch the semicolon comments as follows: # 1) Use this section to make single installer containing # the complete installer ;File “${SOURCE_PATH}\*.*” ;ExecWait ‘“$INSTDIR\setup.exe”’ # 2) Use this for a stub installer with setup extracted # to the SOURCE_PATH ExecWait ‘“${SOURCE_PATH}\setup.exe”’ Following is the listing of the custom-installer.nsi source code: ############################################################### # Hacking Firefox: Custom Installer - version 1.0 # Source: http://www.hackingfirefox.com/custom-installer.nsi ############################################################### !define PRODUCT_NAME “Hacking Firefox Custom Installer” !define SOURCE_PATH “setup” !define CONFIG_INI “${SOURCE_PATH}\config.ini” # Use ZLIB compression to create installer faster # Use LZMA compression to create a smaller installer SetCompressor ZLIB 20_596500 ch13.qxd 6/30/05 3:06 PM Page 258 259 Chapter 13 — Hacking Installation and Deployment Name “${PRODUCT_NAME}” SilentInstall Silent OutFile “hacking_firefox.exe” # Create a random install path in Temp directory for single # installer using the NSIS $PLUGINSDIR variable InstallDir “$PLUGINSDIR” Section “Options” SEC01 # Run installer in Silent Mode - Default Value = Normal WriteINIStr “${CONFIG_INI}” “General” “Run Mode” “Silent” # Choose a custom installation path # ex: “d:\My Custom Apps\Mozilla Firefox” # Other Destination Path values include: # PROGRAMFILESDIR, WINDISK, WINDIR, WINSYSDIR ;WriteINIStr “${CONFIG_INI}” “General” “Path” “[PROGRAMFILESDIR]\Mozilla Firefox” # Disable the Welcome Dialog: Uncomment if changing # “Run Mode” to Normal ;WriteINIStr “${CONFIG_INI}” “Dialog Welcome” “Show Dialog” “FALSE” # Diable the License Dialog: Uncomment if changing # “Run Mode” to Normal ;WriteINIStr “${CONFIG_INI}” “Dialog License” “Show Dialog” “FALSE” # 1) Use this section to make single installer containing # the complete installer File “${SOURCE_PATH}\*.*” ExecWait ‘“$INSTDIR\setup.exe”’ # 2) Use this for a stub installer with setup extracted # to the SOURCE_PATH ;ExecWait ‘“${SOURCE_PATH}\setup.exe”’ SectionEnd Function .onInit # Initialize the random Plugins Directory for installation InitPluginsDir FunctionEnd 20_596500 ch13.qxd 6/30/05 3:06 PM Page 259 260 Part V — Installation, Automation, Tools, and Tricks Other Notable NSIS Code Another good source of NSIS code that I have tapped into in the past was created by Sébastien Delahaye. This code was written for the original Phoenix and Firebird builds, which were pre- release builds of Firefox. The code itself is dated but can be easily modified or updated to fit the current release builds. Some of the functionality that makes this script hold up is that it is localized into different languages, and it can download from the Mozilla servers. For more information or to download this script, visit http://seb.mozdev.org/firebird/. Hacking Microsoft Windows Installers Using a Microsoft Windows Installer (MSI) is one of the hottest topics when talking about deploying Firefox. The ease of integrating an MSI into corporate environments using Windows Active Directory makes using an MSI version of Firefox very desirable. An MSI file is a specific format chiseled out by Microsoft to create a standard installation package based on a simple database of parameters and options and bundled with the corresponding installation files. The benefits of using any MSI are to capitalize on the ability of Windows to allow repair- ing and managing the installation of needed files, as well as provide easy integration with deploy procedures such as Active Directory deployment. Currently slated for the Firefox 1.1 release is an MSI installer version, shown in Figure 13-5, to accompany the existing Windows executable and other platform-specific installers. On the sur- face, this seems to be the solution to everything, but for corporate environments that want to deploy a version prior to 1.1, there are other options. These options include FrontMotion’s MSI installer, shown in Figure 13-6, as well as the ability to create your own using MSI installer tools such as MaSaI or Microsoft’s Installer Software Development Kit. F IGURE 13-5: Official Firefox MSI installer 20_596500 ch13.qxd 6/30/05 3:06 PM Page 260 261 Chapter 13 — Hacking Installation and Deployment To track the progress of the official Firefox MSI installer, visit the following Bugzilla posting: https://bugzilla.mozilla.org/show_bug.cgi?id=231062. F IGURE 13-6: FrontMotion’s MSI installer For more information on FrontMotion’s MSI installer, visit http://www.frontmotion .com/Firefox/. Upon inspecting the official Firefox MSI installer, I found that the contents of the file were merely the extracted setup files, so in reality, the MSI installer from Mozilla is just a wrapper to the official installer. However, the installer available from FrontMotion uses all of the MSI capabilities in installing Firefox, and both MSI installers use the free MAKEMSI tool to build their installer. Another nice feature of the FrontMotion installer is the inclusion of the integrated desktop icon (as mentioned earlier in this chapter) with right-click context menu options. This, coupled with the ability to use the MSI’s repair functionality, makes it an ideal option for deployment in corporate environments. For the latest technical support and help with FrontMotion’s Firefox MSI installer visit this MozillaZine posting: http://forums.mozillazine.org/viewtopic.php?t=138033. 20_596500 ch13.qxd 6/30/05 3:06 PM Page 261 . custom-installer.nsi source code: ############################################################### # Hacking Firefox: Custom Installer - version 1.0 # Source: http://www.hackingfirefox.com/custom-installer.nsi ############################################################### !define. PROD_NAME “Mozilla Firefox !define PROD_PREF “chrome://browser/content/pref/pref.xul” !define TOOL_TIP “${PROD_NAME} - Rediscover the web” !define PROD_GUID “{EC8030F7-C20A-464F-9B0E-13A3A9E97384}” !define. feature into the official Firefox installer, visit the following Bugzilla posting: https://bugzilla.mozilla.org/show_bug .cgi?id =264 889. F IGURE 1 3-3 : Right-click menu for Firefox desktop icon To