I'm also not a 'code guy' so I tend to approach the actual scripting with a 'brute force' way of doing things. I'd appreciate any pointers on a more elegant/efficient script.
I'm using the MUI, scripting by hand as I am still learning the process. I'm attempting to implement these changes in the Firefox profile, but instead of using a batch script I'd like it all to be handled in the "Firefox" section of my overall installer.
Essentially, I'd like to point to the newly installed firefox.js file, search for the following strings, and change the boolean state (true/false) as appropriate for the installation
(default for these for strings is true, I want the script to find them if they exist and change them to false):
pref("browser.shell.checkDefaultBrowser", false)
pref("app.update.enabled", false);
pref("extensions.update.enabled", false);
pref("browser.search.update", false);I'd like to write the script so that I can use an ini file as an input because I can reuse the same concept for editing a bunch of .cfg and .xml files in another installation that takes place later in my script.My brute-force attempt (one of many) follows. I've redacted much of my working script, but left some of the header stuff for scrutiny/improvement suggestions.
I can't get the last piece to work, and I've tried multiple approaches to it, none of which will compile.
Name "FirefoxSilent"
OutFile "FirefoxSilent.exe"
; Includes --------------------------
!include "MUI.nsh"
!include "TextReplace.nsh"
!include "StrRep.nsh"
!include "ReplaceInFile.nsh"
; Defines ---------------------------
!define FIREFOX "Firefox 3.6.3\Firefox Setup 3.6.3\*.*"
; MUI Settings ----------------------
!define MUI_ABORTWARNING
!define MUI_ICON "${INSTALL_ICON}"
; Welcome page
!define MUI_WELCOMEPAGE_TITLE '${WELCOME_TITLE}'
!define MUI_WELCOMEPAGE_TITLE_3LINES
!insertmacro MUI_PAGE_WELCOME
; Components page
!insertmacro MUI_PAGE_COMPONENTS
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define MUI_FINISHPAGE_TITLE '${FINISH_TITLE}'
!define MUI_FINISHPAGE_TITLE_3LINES
!insertmacro MUI_PAGE_FINISH
; Language files
!insertmacro MUI_LANGUAGE "English"
; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
; MUI end --------------------------
; Compression ----------------------
SetCompressor lzma
Section "FireFox" SEC01
SectionIn RO ;make section mandatory for installation
; Installation settings for a silent install of Firefox
WriteINIStr $TEMP\ffconfig.ini Install CloseAppNoPrompt true
WriteINIStr $TEMP\ffconfig.ini Install InstallDirectoryName "Mozilla Firefox"
WriteINIStr $TEMP\ffconfig.ini Install QuickLaunchShortcut false
WriteINIStr $TEMP\ffconfig.ini Install DesktopShortcut false
WriteINIStr $TEMP\ffconfig.ini Install StartMenuShortcuts true
; Use 7zip to unpack the installation files from the Firefox Setup executable from
; http://www.mozilla.com/en-US/firefox/personal.html
; Unpack to a directory with the same name as the downloaded file, then include that
; directory in the File /r statement below (/r means recursive)
File /r "${FIREFOX}"
ExecWait '"$INSTDIR\setup.exe" /INI=$TEMP\ffconfig.ini'
; Disable bookmark import wizard
WriteINIStr "C:\Program Files\Mozilla Firefox\override.ini" XRE EnableProfileMigrator false
; Don't make Firefox check to be default browser
/* THIS IS THE PART THAT DOESN'T WORK */
!insertmacro ReplaceInFile "C:\Program Files\Mozilla Firefox\defaults\pref\firefox.js" 'pref("browser.shell.checkDefaultBrowser", true);' 'pref("browser.shell.checkDefaultBrowser", false);'
; Cleanup
Delete $TEMP\ffconfig.ini ;after install
SectionEnd
I've tried using the following (and others) but none really works as intended in my application: