home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Firefox / FirefoxPortable_20.0_French.paf.exe / Other / Source / FirefoxPortableU.nsi < prev    next >
Text File  |  2013-04-02  |  23KB  |  560 lines

  1. ∩╗┐;Copyright 2004-2013 John T. Haller of PortableApps.com
  2.  
  3. ;Website: http://PortableApps.com/FirefoxPortable
  4.  
  5. ;This software is OSI Certified Open Source Software.
  6. ;OSI Certified is a certification mark of the Open Source Initiative.
  7.  
  8. ;This program is free software; you can redistribute it and/or
  9. ;modify it under the terms of the GNU General Public License
  10. ;as published by the Free Software Foundation; either version 2
  11. ;of the License, or (at your option) any later version.
  12.  
  13. ;This program is distributed in the hope that it will be useful,
  14. ;but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. ;GNU General Public License for more details.
  17.  
  18. ;You should have received a copy of the GNU General Public License
  19. ;along with this program; if not, write to the Free Software
  20. ;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  21.  
  22. !define PORTABLEAPPNAME "Mozilla Firefox, Portable Edition"
  23. !define APPNAME "Firefox"
  24. !define NAME "FirefoxPortable"
  25. !define VER "1.7.8.0"
  26. !define WEBSITE "PortableApps.com/FirefoxPortable"
  27. !define DEFAULTEXE "firefox.exe"
  28. !define DEFAULTAPPDIR "firefox"
  29. !define LAUNCHERLANGUAGE "French"
  30.  
  31. ;=== Program Details
  32. Name "${PORTABLEAPPNAME}"
  33. OutFile "..\..\${NAME}.exe"
  34. Caption "${PORTABLEAPPNAME} | PortableApps.com"
  35. VIProductVersion "${VER}"
  36. VIAddVersionKey ProductName "${PORTABLEAPPNAME}"
  37. VIAddVersionKey Comments "Allows ${APPNAME} to be run from a removable drive.  For additional details, visit ${WEBSITE}"
  38. VIAddVersionKey CompanyName "PortableApps.com"
  39. VIAddVersionKey LegalCopyright "John T. Haller"
  40. VIAddVersionKey FileDescription "${PORTABLEAPPNAME}"
  41. VIAddVersionKey FileVersion "${VER}"
  42. VIAddVersionKey ProductVersion "${VER}"
  43. VIAddVersionKey InternalName "${PORTABLEAPPNAME}"
  44. VIAddVersionKey LegalTrademarks "Firefox is a Registered Trademark of The Mozilla Foundation.  PortableApps.com is a Registered Trademark of Rare Ideas, LLC."
  45. VIAddVersionKey OriginalFilename "${NAME}.exe"
  46. ;VIAddVersionKey PrivateBuild ""
  47. ;VIAddVersionKey SpecialBuild ""
  48.  
  49. ;=== Runtime Switches
  50. CRCCheck On
  51. WindowIcon Off
  52. SilentInstall Silent
  53. AutoCloseWindow True
  54. RequestExecutionLevel user
  55. XPStyle on
  56.  
  57. ; Best Compression
  58. SetCompress Auto
  59. SetCompressor /SOLID lzma
  60. SetCompressorDictSize 32
  61. SetDatablockOptimize On
  62.  
  63. ;=== Include
  64. ;(Standard NSIS)
  65. !include FileFunc.nsh
  66. !insertmacro GetParameters ;Requires NSIS 2.40 or better
  67. !include LogicLib.nsh
  68. !include Registry.nsh
  69. !include TextFunc.nsh
  70. !insertmacro GetParent
  71. !include WordFunc.nsh
  72. !insertmacro VersionCompare
  73.  
  74. ;(NSIS Plugins)
  75. !include TextReplace.nsh
  76.  
  77. ;(Custom)
  78. !include CheckForPlatformSplashDisable.nsh
  79. !include ReplaceInFileWithTextReplace.nsh
  80. !include ReadINIStrWithDefault.nsh
  81. !include SetFileAttributesDirectoryNormal.nsh
  82.  
  83. ;=== Program Icon
  84. Icon "..\..\App\AppInfo\appicon.ico"
  85.  
  86. ;=== Icon & Stye ===
  87. BrandingText "PortableApps.com┬«"
  88.  
  89. ;=== Languages
  90. LoadLanguageFile "${NSISDIR}\Contrib\Language files\${LAUNCHERLANGUAGE}.nlf"
  91. !include PortableApps.comLauncherLANG_${LAUNCHERLANGUAGE}.nsh
  92.  
  93. ;=== Variables
  94. Var PROGRAMDIRECTORY
  95. Var PROFILEDIRECTORY
  96. Var ORIGINALPROFILEDIRECTORY
  97. Var SETTINGSDIRECTORY
  98. Var PLUGINSDIRECTORY
  99. Var ADDITIONALPARAMETERS
  100. Var ALLOWMULTIPLEINSTANCES
  101. Var SKIPCOMPREGFIX
  102. Var EXECSTRING
  103. Var PROGRAMEXECUTABLE
  104. Var INIPATH
  105. Var DISABLESPLASHSCREEN
  106. Var DISABLEINTELLIGENTSTART
  107. Var LOCALHOMEPAGE
  108. Var ISDEFAULTDIRECTORY
  109. Var RUNLOCALLY
  110. Var WAITFORPROGRAM
  111. Var LASTPROFILEDIRECTORY
  112. Var APPDATAPATH
  113. Var SECONDARYLAUNCH
  114. Var MOZILLAORGKEYEXISTS
  115. Var HKLMMOZILLAORGKEYEXISTS
  116. Var MISSINGFILEORPATH
  117. Var CRASHREPORTSDIREXISTS
  118. Var EXTENSIONSDIREXISTS
  119. Var bolHKCUSoftwareMozillaFirefoxCrashReporterExists
  120. Var bolHKCUSoftwareMozillaFirefoxExists
  121. Var bolHKCUSoftwareMozillaExists
  122. Var SubmitCrashReportBackup
  123.  
  124. Section "Main"
  125.     ;=== Setup variables
  126.     ReadEnvStr $APPDATAPATH "APPDATA"
  127.  
  128.     ;=== Find the INI file, if there is one
  129.         IfFileExists "$EXEDIR\${NAME}.ini" "" NoINI
  130.             StrCpy "$INIPATH" "$EXEDIR"
  131.  
  132.         ;=== Read the parameters from the INI file
  133.         ${ReadINIStrWithDefault} $0 "$INIPATH\${NAME}.ini" "${NAME}" "${APPNAME}Directory" "App\${DEFAULTAPPDIR}"
  134.         StrCpy $PROGRAMDIRECTORY "$EXEDIR\$0"
  135.         ${ReadINIStrWithDefault} $0 "$INIPATH\${NAME}.ini" "${NAME}" "ProfileDirectory" "Data\profile"
  136.         StrCpy $PROFILEDIRECTORY "$EXEDIR\$0"
  137.         ${ReadINIStrWithDefault} $0 "$INIPATH\${NAME}.ini" "${NAME}" "SettingsDirectory" "Data\settings"
  138.         StrCpy $SETTINGSDIRECTORY "$EXEDIR\$0"
  139.         ${ReadINIStrWithDefault} $0 "$INIPATH\${NAME}.ini" "${NAME}" "PluginsDirectory" "Data\plugins"
  140.         StrCpy $PLUGINSDIRECTORY "$EXEDIR\$0"
  141.         ${ReadINIStrWithDefault} $ADDITIONALPARAMETERS "$INIPATH\${NAME}.ini" "${NAME}" "AdditionalParameters" ""
  142.         ${ReadINIStrWithDefault} $ALLOWMULTIPLEINSTANCES "$INIPATH\${NAME}.ini" "${NAME}" "AllowMultipleInstances" "false"
  143.         ${ReadINIStrWithDefault} $SKIPCOMPREGFIX "$INIPATH\${NAME}.ini" "${NAME}" "SkipCompregFix" "false"
  144.         ${ReadINIStrWithDefault} $PROGRAMEXECUTABLE "$INIPATH\${NAME}.ini" "${NAME}" "${APPNAME}Executable" "${DEFAULTEXE}"
  145.         ${ReadINIStrWithDefault} $WAITFORPROGRAM "$INIPATH\${NAME}.ini" "${NAME}" "WaitFor${APPNAME}" "false"
  146.         ${ReadINIStrWithDefault} $DISABLESPLASHSCREEN "$INIPATH\${NAME}.ini" "${NAME}" "DisableSplashScreen" "false"
  147.         ${ReadINIStrWithDefault} $DISABLEINTELLIGENTSTART "$INIPATH\${NAME}.ini" "${NAME}" "DisableIntelligentStart" "false"
  148.         ${ReadINIStrWithDefault} $LOCALHOMEPAGE "$INIPATH\${NAME}.ini" "${NAME}" "LocalHomepage" ""
  149.         ${ReadINIStrWithDefault} $RUNLOCALLY "$INIPATH\${NAME}.ini" "${NAME}" "RunLocally" "false"
  150.         StrCmp $RUNLOCALLY "true" "" CheckIfDefaultDirectories
  151.             StrCpy $WAITFORPROGRAM "true"
  152.  
  153.     CheckIfDefaultDirectories:
  154.         ;=== Check if default directories
  155.         StrCmp $PROGRAMDIRECTORY "$EXEDIR\App\${DEFAULTAPPDIR}" "" EndINI
  156.         StrCmp $PROFILEDIRECTORY "$EXEDIR\Data\profile" "" EndINI
  157.         StrCmp $PLUGINSDIRECTORY "$EXEDIR\Data\plugins" "" EndINI
  158.         StrCmp $SETTINGSDIRECTORY "$EXEDIR\Data\settings" "" EndINI
  159.         StrCpy $ISDEFAULTDIRECTORY "true"
  160.     
  161.     EndINI:
  162.         IfFileExists "$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" FoundProgramEXE NoProgramEXE
  163.  
  164.     NoINI:
  165.         ;=== No INI file, so we'll use the defaults
  166.         StrCpy $ADDITIONALPARAMETERS ""
  167.         StrCpy $ALLOWMULTIPLEINSTANCES "false"
  168.         StrCpy $SKIPCOMPREGFIX "false"
  169.         StrCpy $WAITFORPROGRAM "false"
  170.         StrCpy $PROGRAMEXECUTABLE "${DEFAULTEXE}"
  171.         StrCpy $DISABLESPLASHSCREEN "false"
  172.         StrCpy $DISABLEINTELLIGENTSTART "false"
  173.  
  174.         IfFileExists "$EXEDIR\App\${DEFAULTAPPDIR}\${DEFAULTEXE}" "" CheckPortableProgramDIR
  175.             StrCpy $PROGRAMDIRECTORY "$EXEDIR\App\${DEFAULTAPPDIR}"
  176.             StrCpy $PROFILEDIRECTORY "$EXEDIR\Data\profile"
  177.             StrCpy $PLUGINSDIRECTORY "$EXEDIR\Data\plugins"
  178.             StrCpy $SETTINGSDIRECTORY "$EXEDIR\Data\settings"
  179.             StrCpy $ISDEFAULTDIRECTORY "true"
  180.             Goto FoundProgramEXE
  181.     
  182.     CheckPortableProgramDIR:
  183.             IfFileExists "$EXEDIR\${NAME}\App\${DEFAULTAPPDIR}\${DEFAULTEXE}" "" NoProgramEXE
  184.             StrCpy $PROGRAMDIRECTORY "$EXEDIR\${NAME}\App\${DEFAULTAPPDIR}"
  185.             StrCpy $PROFILEDIRECTORY "$EXEDIR\${NAME}\Data\profile"
  186.             StrCpy $PLUGINSDIRECTORY "$EXEDIR\${NAME}\Data\plugins"
  187.             StrCpy $SETTINGSDIRECTORY "$EXEDIR\${NAME}\Data\settings"
  188.             Goto FoundProgramEXE
  189.  
  190.     NoProgramEXE:
  191.         ;=== Program executable not where expected
  192.         StrCpy $MISSINGFILEORPATH $PROGRAMEXECUTABLE
  193.         MessageBox MB_OK|MB_ICONEXCLAMATION `$(LauncherFileNotFound)`
  194.         Abort
  195.  
  196.     FoundProgramEXE:
  197.         StrCpy $ORIGINALPROFILEDIRECTORY $PROFILEDIRECTORY
  198.         
  199.         IfFileExists "$APPDATA\Mozilla\Firefox\*.*" CheckUserRegistryKey
  200.             StrCpy $WAITFORPROGRAM "true"
  201.         CheckUserRegistryKey:
  202.             ${registry::KeyExists} "HKCU\Software\mozilla.org" $R0
  203.             StrCmp $R0 "-1" CheckMachineRegistryKey ;=== If it doesn't exist, skip the next line
  204.             StrCpy $MOZILLAORGKEYEXISTS "true"
  205.         CheckMachineRegistryKey:
  206.             ${registry::KeyExists} "HKLM\Software\mozilla.org" $R0
  207.             StrCmp $R0 "-1" CheckOtherKeys ;=== If it doesn't exist, skip the next line
  208.             StrCpy $HKLMMOZILLAORGKEYEXISTS "true"
  209.         CheckOtherKeys:
  210.             ${registry::KeyExists} "HKCU\Software\Mozilla" $R0
  211.             ${If} $R0 != "-1"
  212.                 StrCpy $bolHKCUSoftwareMozillaExists true
  213.                 ${registry::KeyExists} "HKCU\Software\Mozilla\Firefox" $R0
  214.                 ${If} $R0 != "-1"
  215.                     StrCpy $bolHKCUSoftwareMozillaFirefoxExists true
  216.                     ${registry::KeyExists} "HKCU\Software\Mozilla\Firefox\Crash Reporter" $R0
  217.                     ${If} $R0 != "-1"
  218.                         StrCpy $bolHKCUSoftwareMozillaFirefoxCrashReporterExists true
  219.                         ${registry::Read} "HKCU\Software\Mozilla\Firefox\Crash Reporter" "SubmitCrashReport" $SubmitCrashReportBackup $R2
  220.                     ${EndIf}
  221.                 ${EndIf}    
  222.             ${EndIf}
  223.  
  224.     ;CheckIfRunning:
  225.         ;=== Check if running
  226.         StrCmp $ALLOWMULTIPLEINSTANCES "true" ProfileWork
  227.         FindProcDLL::FindProc "firefox.exe"
  228.         StrCmp $R0 "1" "" CheckForCrashReports
  229.             ;=== Already running, check if it is using the portable profile
  230.             IfFileExists "$PROFILEDIRECTORY\parent.lock" "" WarnAnotherInstance
  231.                 StrCpy $SECONDARYLAUNCH "true"
  232.                 Goto RunProgram
  233.  
  234.     WarnAnotherInstance:
  235.         MessageBox MB_OK|MB_ICONINFORMATION `$(LauncherAlreadyRunning)`
  236.         Abort
  237.     
  238.     CheckForCrashReports:
  239.         IfFileExists "$APPDATA\Mozilla\Firefox\Crash Reports\*.*" "" CheckForExtensionsDirectory
  240.             Rename "$APPDATA\Mozilla\Firefox\Crash Reports" "$APPDATA\Mozilla\Firefox\Crash Reports-BackupByFirefoxPortable"
  241.             StrCpy $CRASHREPORTSDIREXISTS "true"
  242.             StrCpy $WAITFORPROGRAM "true"
  243.  
  244.     CheckForExtensionsDirectory:
  245.         IfFileExists "$APPDATA\Mozilla\Extensions\*.*" "" ProfileWork
  246.             Rename "$APPDATA\Mozilla\Extensions" "$APPDATA\Mozilla\Extensions-BackupByFirefoxPortable"
  247.             StrCpy $EXTENSIONSDIREXISTS "true"
  248.             StrCpy $WAITFORPROGRAM "true"
  249.     
  250.     ProfileWork:
  251.         ;=== Check for an existing profile
  252.         IfFileExists "$PROFILEDIRECTORY\prefs.js" ProfileFound
  253.             ;=== No profile was found
  254.             StrCmp $ISDEFAULTDIRECTORY "true" CopyDefaultProfile CreateProfile
  255.     
  256.     CopyDefaultProfile:
  257.         CreateDirectory "$EXEDIR\Data"
  258.         CreateDirectory "$EXEDIR\Data\plugins"
  259.         CreateDirectory "$EXEDIR\Data\profile"
  260.         CreateDirectory "$EXEDIR\Data\settings"
  261.         CopyFiles /SILENT $EXEDIR\App\DefaultData\plugins\*.* $EXEDIR\Data\plugins
  262.         CopyFiles /SILENT $EXEDIR\App\DefaultData\profile\*.* $EXEDIR\Data\profile
  263.         CopyFiles /SILENT $EXEDIR\App\DefaultData\settings\*.* $EXEDIR\Data\settings
  264.         GoTo ProfileFound
  265.     
  266.     CreateProfile:
  267.         IfFileExists "$PROFILEDIRECTORY\*.*" ProfileFound
  268.         CreateDirectory "$PROFILEDIRECTORY"
  269.  
  270.     ProfileFound:
  271.         IfFileExists "$SETTINGSDIRECTORY\FirefoxPortableSettings.ini" SettingsFound
  272.             CreateDirectory "$SETTINGSDIRECTORY"
  273.             FileOpen $R0 "$SETTINGSDIRECTORY\FirefoxPortableSettings.ini" w
  274.             FileClose $R0
  275.             WriteINIStr "$SETTINGSDIRECTORY\FirefoxPortableSettings.ini" "FirefoxPortableSettings" "LastProfileDirectory" "NONE"
  276.  
  277.     SettingsFound:
  278.         ${ReadINIStrWithDefault} $R0 "$SETTINGSDIRECTORY\${NAME}Settings.ini" "${NAME}Settings" "SubmitCrashReport" ""
  279.         ${If} $R0 != ""
  280.             ${registry::Write} "HKCU\Software\Mozilla\Firefox\Crash Reporter" "SubmitCrashReport" "$R0" "REG_DWORD" $R1
  281.         ${EndIf}
  282.         ${If} ${FileExists} "$EXEDIR\LupoApp.ini"
  283.             ;Upgrade or install sans the PortableApps.com Installer which can cause compatibility issues
  284.             ${ReadINIStrWithDefault} $0 "$EXEDIR\App\AppInfo\appinfo.ini" "Version" "PackageVersion" "0.0.0.0"
  285.             ${ReadINIStrWithDefault} $1 "$SETTINGSDIRECTORY\FirefoxPortableSettings.ini" "FirefoxPortableSettings" "InvalidPackageWarningShown" "0.0.0.0"
  286.             ${VersionCompare} $0 $1 $2
  287.             ${If} $2 == 1
  288.                 MessageBox MB_OK|MB_ICONEXCLAMATION `Warning: ${PORTABLEAPPNAME} was installed or upgraded without using the official PortableApps.com Installer which can cause compatibility issues and may be a violation of the application's license. You may encounter issues while using this application. Please visit PortableApps.com to obtain the official release of this application to install or upgrade.`
  289.                 WriteINIStr "$SETTINGSDIRECTORY\FirefoxPortableSettings.ini" "FirefoxPortableSettings" "InvalidPackageWarningShown" $0
  290.             ${EndIf}
  291.         ${EndIf}
  292.     
  293.     
  294.         ;=== Check for read/write
  295.         StrCmp $RUNLOCALLY "true" DisplaySplash
  296.         ClearErrors
  297.         FileOpen $R0 "$PROFILEDIRECTORY\writetest.temp" w
  298.         IfErrors "" WriteSuccessful
  299.             ;== Write failed, so we're read-only
  300.             MessageBox MB_YESNO|MB_ICONQUESTION `$(LauncherAskCopyLocal)` IDYES SwitchToRunLocally
  301.             MessageBox MB_OK|MB_ICONINFORMATION `$(LauncherNoReadOnly)`
  302.             Abort
  303.  
  304.     SwitchToRunLocally:
  305.         StrCpy $RUNLOCALLY "true"
  306.         StrCpy $WAITFORPROGRAM "true"
  307.         Goto DisplaySplash
  308.     
  309.     WriteSuccessful:
  310.         FileClose $R0
  311.         Delete "$PROFILEDIRECTORY\writetest.temp"
  312.     
  313.     DisplaySplash:
  314.         ${CheckForPlatformSplashDisable} $DISABLESPLASHSCREEN
  315.         StrCmp $DISABLESPLASHSCREEN "true" SkipSplashScreen
  316.             ;=== Show the splash screen before processing the files
  317.             InitPluginsDir
  318.             File /oname=$PLUGINSDIR\splash.jpg "${NAME}.jpg"
  319.             newadvsplash::show /NOUNLOAD 2000 0 0 -1 /L $PLUGINSDIR\splash.jpg
  320.  
  321.     SkipSplashScreen:
  322.         ;=== Run locally if needed (aka Portable Firefox Live)
  323.         StrCmp $RUNLOCALLY "true" "" CompareProfilePath
  324.         RMDir /r "$TEMP\${NAME}\"
  325.         CreateDirectory $TEMP\${NAME}\profile
  326.         CreateDirectory $TEMP\${NAME}\plugins
  327.         CreateDirectory $TEMP\${NAME}\program
  328.         CopyFiles /SILENT $PROFILEDIRECTORY\*.* $TEMP\${NAME}\profile
  329.         StrCpy $PROFILEDIRECTORY $TEMP\${NAME}\profile
  330.         CopyFiles /SILENT $PLUGINSDIRECTORY\*.* $TEMP\${NAME}\plugins
  331.         StrCpy $PLUGINSDIRECTORY $TEMP\${NAME}\plugins
  332.         CopyFiles /SILENT $PROGRAMDIRECTORY\*.* $TEMP\${NAME}\program
  333.         StrCpy $PROGRAMDIRECTORY $TEMP\${NAME}\program
  334.         ${SetFileAttributesDirectoryNormal} "$TEMP\${NAME}"
  335.  
  336.     CompareProfilePath:
  337.         ReadINIStr $LASTPROFILEDIRECTORY "$SETTINGSDIRECTORY\${NAME}Settings.ini" "${NAME}Settings" "LastProfileDirectory"
  338.         StrCmp $PROFILEDIRECTORY $LASTPROFILEDIRECTORY "" RememberProfilePath
  339.             StrCmp $DISABLEINTELLIGENTSTART "true" RememberProfilePath
  340.                 StrCpy $SKIPCOMPREGFIX "true"
  341.     
  342.     RememberProfilePath:
  343.         WriteINIStr "$SETTINGSDIRECTORY\${NAME}Settings.ini" "${NAME}Settings" "LastProfileDirectory" "$PROFILEDIRECTORY"
  344.  
  345.     ;FixPrefsJs:
  346.         IfFileExists "$PROFILEDIRECTORY\prefs.js" "" FixOtherFiles
  347.         StrCmp $LASTPROFILEDIRECTORY "NONE" FixPrefsJsPart2
  348.         StrCpy $2 $LASTPROFILEDIRECTORY 1 ;Last drive letter
  349.         StrCpy $3 $PROFILEDIRECTORY 1 ;Current drive letter
  350.         StrCmp $2 $3 FixPrefsJsPart2 ;If no change, move on
  351.         
  352.         ;=== Replace drive letters without impacting other instances of the letter in prefs.js
  353.         ${ReplaceInFileCS} "$PROFILEDIRECTORY\prefs.js" `file:///$2` `file:///$3`
  354.         ${ReplaceInFileCS} "$PROFILEDIRECTORY\prefs.js" `", "$2:\\` `", "$3:\\`
  355.     
  356.     FixPrefsJsPart2:
  357.         ;=== Be sure the default browser check is disabled
  358.         FileOpen $0 "$PROFILEDIRECTORY\prefs.js" a
  359.         FileSeek $0 0 END
  360.         FileWriteByte $0 "13"
  361.         FileWriteByte $0 "10"
  362.         FileWrite $0 `user_pref("browser.shell.checkDefaultBrowser", false);`
  363.         FileWriteByte $0 "13"
  364.         FileWriteByte $0 "10"
  365.         StrCmp "$LOCALHOMEPAGE" "" FixPrefsJsClose
  366.         FileWrite $0 `user_pref("browser.startup.homepage", "file:///$EXEDIR/$LOCALHOMEPAGE");`
  367.         FileWriteByte $0 "13"
  368.         FileWriteByte $0 "10"
  369.  
  370.     FixPrefsJsClose:
  371.         FileClose $0 
  372.  
  373.     FixOtherFiles:
  374.         StrCmp $LASTPROFILEDIRECTORY "NONE" RunProgram
  375.         ${GetParent} $LASTPROFILEDIRECTORY $0
  376.         ${GetParent} $0 $0
  377.         StrCpy $0 '$0\' ;last FirefoxPortable directory
  378.         ${GetParent} $ORIGINALPROFILEDIRECTORY $1
  379.         ${GetParent} $1 $1
  380.         StrCpy $1 '$1\' ;current FirefoxPortable directory
  381.         StrCmp $0 $1 RunProgram
  382.         ${If} ${FileExists} "$PROFILEDIRECTORY\pluginreg.dat"
  383.             ${ReplaceInFile} "$PROFILEDIRECTORY\pluginreg.dat" $0 $1
  384.         ${EndIf}
  385.         ${If} ${FileExists} "$PROFILEDIRECTORY\extensions.ini"
  386.             ${ReplaceInFile} "$PROFILEDIRECTORY\extensions.ini" $0 $1
  387.             ;Update extensions SQL
  388.         ${EndIf}
  389.         ${If} ${FileExists} "$PROFILEDIRECTORY\extensions.sqlite"
  390.             nsExec::Exec `"$EXEDIR\App\Bin\sqlite3.exe" "$PROFILEDIRECTORY\extensions.sqlite" "UPDATE addon SET descriptor = '$1' || SUBSTR(descriptor,(LENGTH('$0')+1)) WHERE descriptor LIKE '$0%';"`
  391.         ${EndIf}
  392.         ${If} ${FileExists} "$PROFILEDIRECTORY\mimeTypes.rdf"
  393.             ${ReplaceInFile} "$PROFILEDIRECTORY\mimeTypes.rdf" $0 $1
  394.         ${EndIf}
  395.         ${GetParent} $LASTPROFILEDIRECTORY $0
  396.         ${GetParent} $0 $0
  397.         ${GetParent} $0 $0
  398.         StrCpy $0 '$0\' ;last PortableApps directory
  399.         ${GetParent} $ORIGINALPROFILEDIRECTORY $1
  400.         ${GetParent} $1 $1
  401.         ${GetParent} $1 $1
  402.         StrCpy $1 '$1\' ;current PortableApps directory
  403.         StrCmp $0 $1 RunProgram
  404.         ${If} ${FileExists} "$PROFILEDIRECTORY\mimeTypes.rdf"
  405.             ${ReplaceInFile} "$PROFILEDIRECTORY\mimeTypes.rdf" $0 $1
  406.         ${EndIf}
  407.  
  408.     RunProgram:
  409.         StrCmp $SKIPCOMPREGFIX "true" GetPassedParameters
  410.  
  411.         ;=== Delete component registry to ensure compatibility with all extensions
  412.         Delete $PROFILEDIRECTORY\compreg.dat
  413.  
  414.     GetPassedParameters:
  415.         ;=== Get any passed parameters
  416.         ${GetParameters} $0
  417.         StrCmp "'$0'" "''" "" LaunchProgramParameters
  418.  
  419.         ;=== No parameters
  420.         StrCpy $EXECSTRING `"$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" -profile "$PROFILEDIRECTORY"`
  421.         Goto CheckMultipleInstances
  422.  
  423.     LaunchProgramParameters:
  424.         StrCpy $EXECSTRING `"$PROGRAMDIRECTORY\$PROGRAMEXECUTABLE" -profile "$PROFILEDIRECTORY" $0`
  425.  
  426.     CheckMultipleInstances:
  427.         StrCmp $ALLOWMULTIPLEINSTANCES "true" "" AdditionalParameters
  428.         StrCpy $EXECSTRING `$EXECSTRING -no-remote`
  429.  
  430.     AdditionalParameters:
  431.         StrCmp $ADDITIONALPARAMETERS "" PluginsEnvironment
  432.  
  433.         ;=== Additional Parameters
  434.         StrCpy $EXECSTRING `$EXECSTRING $ADDITIONALPARAMETERS`
  435.  
  436.     PluginsEnvironment:
  437.         ;=== Set the plugins directory if we have a path
  438.         ${IfNot} ${FileExists} "$PLUGINSDIRECTORY\*.*"
  439.             StrCpy $PLUGINSDIRECTORY ""
  440.         ${EndIf}
  441.         ${GetParent} $EXEDIR $0
  442.         ${If} ${FileExists} "$0\CommonFiles\Java\bin\plugin2\*.*"
  443.             ${If} $PLUGINSDIRECTORY != ""
  444.                 StrCpy $PLUGINSDIRECTORY "$PLUGINSDIRECTORY;$0\CommonFiles\Java\bin\plugin2"
  445.             ${Else}
  446.                 StrCpy $PLUGINSDIRECTORY "$0\CommonFiles\Java\bin\plugin2"
  447.             ${EndIf}
  448.         ${ElseIf} ${FileExists} "$0\CommonFiles\Java\bin\new_plugin\*.*"
  449.             ${If} $PLUGINSDIRECTORY != ""
  450.                 StrCpy $PLUGINSDIRECTORY "$PLUGINSDIRECTORY;$0\CommonFiles\Java\bin\new_plugin"
  451.             ${Else}
  452.                 StrCpy $PLUGINSDIRECTORY "$0\CommonFiles\Java\bin\new_plugin"
  453.             ${EndIf}
  454.         ${EndIf}
  455.         ${If} ${FileExists} "$0\CommonFiles\Silverlight\files\*.*"
  456.             ${If} $PLUGINSDIRECTORY != ""
  457.                 StrCpy $PLUGINSDIRECTORY "$PLUGINSDIRECTORY;$0\CommonFiles\Silverlight\files"
  458.             ${Else}
  459.                 StrCpy $PLUGINSDIRECTORY "$0\CommonFiles\Silverlight\files"
  460.             ${EndIf}
  461.         ${EndIf}
  462.         ${If} ${FileExists} "$0\CommonFiles\Flash\files\*.*"
  463.             ${If} $PLUGINSDIRECTORY != ""
  464.                 StrCpy $PLUGINSDIRECTORY "$PLUGINSDIRECTORY;$0\CommonFiles\Flash\files"
  465.             ${Else}
  466.                 StrCpy $PLUGINSDIRECTORY "$0\CommonFiles\Flash\files"
  467.             ${EndIf}
  468.         ${EndIf}
  469.         ${If} ${FileExists} "$0\CommonFiles\BrowserPlugins\*.*"
  470.             ${If} $PLUGINSDIRECTORY != ""
  471.                 StrCpy $PLUGINSDIRECTORY "$PLUGINSDIRECTORY;$0\CommonFiles\BrowserPlugins"
  472.             ${Else}
  473.                 StrCpy $PLUGINSDIRECTORY "$0\CommonFiles\BrowserPlugins"
  474.             ${EndIf}
  475.         ${EndIf}
  476.         
  477.         StrCmp $PLUGINSDIRECTORY "" LaunchNow
  478.             System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("MOZ_PLUGIN_PATH", "$PLUGINSDIRECTORY").r0'
  479.  
  480.     LaunchNow:
  481.         System::Call 'Kernel32::SetEnvironmentVariable(t, t) i("MOZ_CRASHREPORTER_DATA_DIRECTORY", "$PROFILEDIRECTORY\CrashReports").r0'
  482.         
  483.         StrCmp $SECONDARYLAUNCH "true" StartProgramAndExit
  484.         StrCmp $WAITFORPROGRAM "true" "" StartProgramAndExit
  485.         ExecWait $EXECSTRING
  486.  
  487.     CheckRunning:
  488.         Sleep 2000
  489.         StrCmp $ALLOWMULTIPLEINSTANCES "true" CheckIfRemoveLocalFiles
  490.         FindProcDLL::FindProc "firefox.exe"                  
  491.         StrCmp $R0 "1" CheckRunning CleanupRunLocally
  492.     
  493.     StartProgramAndExit:
  494.         Exec $EXECSTRING
  495.         Goto TheEnd
  496.     
  497.     CleanupRunLocally:
  498.         StrCmp $RUNLOCALLY "true" "" CheckIfRemoveLocalFiles
  499.         RMDir /r "$TEMP\${NAME}\"
  500.  
  501.     CheckIfRemoveLocalFiles:
  502.         FindProcDLL::FindProc "firefox.exe"
  503.         Pop $R0
  504.         StrCmp $R0 "1" TheEnd RemoveLocalFiles
  505.  
  506.     RemoveLocalFiles:
  507.         StrCmp $ALLOWMULTIPLEINSTANCES "true" RemoveLocalFiles2
  508.         RMDir /r "$APPDATA\Mozilla\Firefox\Crash Reports\"
  509.         Rename "$APPDATA\Mozilla\Firefox\Crash Reports-BackupByFirefoxPortable" "$APPDATA\Mozilla\Firefox\Crash Reports"
  510.         
  511.     RemoveLocalFiles2:
  512.         StrCmp $ALLOWMULTIPLEINSTANCES "true" RemoveLocalFiles3
  513.         RMDir /r "$APPDATA\Mozilla\Extensions\"
  514.         Rename "$APPDATA\Mozilla\Extensions-BackupByFirefoxPortable" "$APPDATA\Mozilla\Extensions"
  515.         
  516.     RemoveLocalFiles3:
  517.         Delete "$APPDATA\Mozilla\Firefox\pluginreg.dat"
  518.         RMDir "$APPDATA\Mozilla\Firefox\Profiles\" ;=== Will only delete if empty (no /r switch)
  519.         RMDir "$APPDATA\Mozilla\Firefox\Profile\" ;=== Will only delete if empty (no /r switch)
  520.         RMDir "$APPDATA\Mozilla\Firefox\" ;=== Will only delete if empty (no /r switch)
  521.         RMDir "$APPDATA\Mozilla\" ;=== Will only delete if empty (no /r switch)
  522.         RMDir "$LOCALAPPDATA\Mozilla\Firefox\firefox\updates\0" ;=== Will only delete if empty (no /r switch)
  523.         RMDir "$LOCALAPPDATA\Mozilla\Firefox\firefox\updates" ;=== Will only delete if empty (no /r switch)
  524.         RMDir "$LOCALAPPDATA\Mozilla\Firefox\firefox" ;=== Will only delete if empty (no /r switch)
  525.         RMDir "$LOCALAPPDATA\Mozilla\Firefox\" ;=== Will only delete if empty (no /r switch)
  526.         RMDir "$LOCALAPPDATA\Mozilla\" ;=== Will only delete if empty (no /r switch)
  527.         StrCmp $MOZILLAORGKEYEXISTS "true" RemoveMachineRegistryKey
  528.             ${registry::DeleteKey} "HKEY_CURRENT_USER\Software\mozilla.org" $R0
  529.         RemoveMachineRegistryKey:
  530.             StrCmp $HKLMMOZILLAORGKEYEXISTS "true" RemoveOtherKeys
  531.                 ${registry::KeyExists} "HKLM\Software\mozilla.org" $R0
  532.                     StrCmp $R0 "-1" RemoveOtherKeys ;=== If it doesn't exist, skip the next line
  533.                         UserInfo::GetAccountType
  534.                         Pop $0
  535.                         StrCmp $0 "Guest" RemoveOtherKeys
  536.                         StrCmp $0 "User" RemoveOtherKeys
  537.                         ${registry::DeleteKey} "HKLM\Software\mozilla.org" $R0
  538.         RemoveOtherKeys:
  539.             ;Store the crash report setting
  540.             ${registry::Read} "HKCU\Software\Mozilla\Firefox\Crash Reporter" "SubmitCrashReport" $R1 $R2
  541.             WriteINIStr "$SETTINGSDIRECTORY\${NAME}Settings.ini" "${NAME}Settings" "SubmitCrashReport" "$R1"
  542.             
  543.             ${If} $bolHKCUSoftwareMozillaExists == true
  544.                 ${If} $bolHKCUSoftwareMozillaFirefoxExists == true
  545.                     ${If} $bolHKCUSoftwareMozillaFirefoxCrashReporterExists == true
  546.                         ${registry::Write} "HKCU\Software\Mozilla\Firefox\Crash Reporter" "SubmitCrashReport" "$SubmitCrashReportBackup" "REG_DWORD" $R1
  547.                     ${Else}
  548.                         ${registry::DeleteKey} "HKCU\Software\Mozilla\Firefox\Crash Reporter" $R0
  549.                     ${EndIf}
  550.                 ${Else}
  551.                     ${registry::DeleteKey} "HKCU\Software\Mozilla\Firefox" $R0
  552.                 ${EndIf}                
  553.             ${Else}
  554.                 ${registry::DeleteKey} "HKCU\Software\Mozilla" $R0
  555.             ${EndIf}
  556.  
  557.     TheEnd:
  558.         ${registry::Unload}
  559.         newadvsplash::stop /WAIT
  560. SectionEnd