browser/installer/windows/nsis/uninstaller.nsi

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/installer/windows/nsis/uninstaller.nsi	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,679 @@
     1.4 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 +
     1.8 +# Required Plugins:
     1.9 +# AppAssocReg http://nsis.sourceforge.net/Application_Association_Registration_plug-in
    1.10 +# CityHash    http://mxr.mozilla.org/mozilla-central/source/other-licenses/nsis/Contrib/CityHash
    1.11 +# ShellLink   http://nsis.sourceforge.net/ShellLink_plug-in
    1.12 +# UAC         http://nsis.sourceforge.net/UAC_plug-in
    1.13 +
    1.14 +; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs
    1.15 +!verbose 3
    1.16 +
    1.17 +; 7-Zip provides better compression than the lzma from NSIS so we add the files
    1.18 +; uncompressed and use 7-Zip to create a SFX archive of it
    1.19 +SetDatablockOptimize on
    1.20 +SetCompress off
    1.21 +CRCCheck on
    1.22 +
    1.23 +RequestExecutionLevel user
    1.24 +
    1.25 +; The commands inside this ifdef require NSIS 3.0a2 or greater so the ifdef can
    1.26 +; be removed after we require NSIS 3.0a2 or greater.
    1.27 +!ifdef NSIS_PACKEDVERSION
    1.28 +  Unicode true
    1.29 +  ManifestSupportedOS all
    1.30 +  ManifestDPIAware true
    1.31 +!endif
    1.32 +
    1.33 +!addplugindir ./
    1.34 +
    1.35 +; On Vista and above attempt to elevate Standard Users in addition to users that
    1.36 +; are a member of the Administrators group.
    1.37 +!define NONADMIN_ELEVATE
    1.38 +
    1.39 +; prevents compiling of the reg write logging.
    1.40 +!define NO_LOG
    1.41 +
    1.42 +!define MaintUninstallKey \
    1.43 + "Software\Microsoft\Windows\CurrentVersion\Uninstall\MozillaMaintenanceService"
    1.44 +
    1.45 +Var TmpVal
    1.46 +Var MaintCertKey
    1.47 +
    1.48 +; Other included files may depend upon these includes!
    1.49 +; The following includes are provided by NSIS.
    1.50 +!include FileFunc.nsh
    1.51 +!include LogicLib.nsh
    1.52 +!include MUI.nsh
    1.53 +!include WinMessages.nsh
    1.54 +!include WinVer.nsh
    1.55 +!include WordFunc.nsh
    1.56 +
    1.57 +!insertmacro GetSize
    1.58 +!insertmacro StrFilter
    1.59 +!insertmacro WordReplace
    1.60 +
    1.61 +!insertmacro un.GetParent
    1.62 +
    1.63 +; The following includes are custom.
    1.64 +!include branding.nsi
    1.65 +!include defines.nsi
    1.66 +!include common.nsh
    1.67 +!include locales.nsi
    1.68 +
    1.69 +; This is named BrandShortName helper because we use this for software update
    1.70 +; post update cleanup.
    1.71 +VIAddVersionKey "FileDescription" "${BrandShortName} Helper"
    1.72 +VIAddVersionKey "OriginalFilename" "helper.exe"
    1.73 +
    1.74 +!insertmacro AddDisabledDDEHandlerValues
    1.75 +!insertmacro CleanVirtualStore
    1.76 +!insertmacro ElevateUAC
    1.77 +!insertmacro GetLongPath
    1.78 +!insertmacro GetPathFromString
    1.79 +!insertmacro InitHashAppModelId
    1.80 +!insertmacro IsHandlerForInstallDir
    1.81 +!insertmacro IsPinnedToTaskBar
    1.82 +!insertmacro IsUserAdmin
    1.83 +!insertmacro LogDesktopShortcut
    1.84 +!insertmacro LogQuickLaunchShortcut
    1.85 +!insertmacro LogStartMenuShortcut
    1.86 +!insertmacro PinnedToStartMenuLnkCount
    1.87 +!insertmacro RegCleanAppHandler
    1.88 +!insertmacro RegCleanMain
    1.89 +!insertmacro RegCleanUninstall
    1.90 +!ifdef MOZ_METRO
    1.91 +!insertmacro RemoveDEHRegistrationIfMatching
    1.92 +!endif
    1.93 +!insertmacro SetAppLSPCategories
    1.94 +!insertmacro SetBrandNameVars
    1.95 +!insertmacro UpdateShortcutAppModelIDs
    1.96 +!insertmacro UnloadUAC
    1.97 +!insertmacro WriteRegDWORD2
    1.98 +!insertmacro WriteRegStr2
    1.99 +!insertmacro CheckIfRegistryKeyExists
   1.100 +
   1.101 +!insertmacro un.ChangeMUIHeaderImage
   1.102 +!insertmacro un.CheckForFilesInUse
   1.103 +!insertmacro un.CleanUpdateDirectories
   1.104 +!insertmacro un.CleanVirtualStore
   1.105 +!insertmacro un.DeleteShortcuts
   1.106 +!insertmacro un.GetLongPath
   1.107 +!insertmacro un.GetSecondInstallPath
   1.108 +!insertmacro un.InitHashAppModelId
   1.109 +!insertmacro un.ManualCloseAppPrompt
   1.110 +!insertmacro un.ParseUninstallLog
   1.111 +!insertmacro un.RegCleanAppHandler
   1.112 +!insertmacro un.RegCleanFileHandler
   1.113 +!insertmacro un.RegCleanMain
   1.114 +!insertmacro un.RegCleanUninstall
   1.115 +!insertmacro un.RegCleanProtocolHandler
   1.116 +!ifdef MOZ_METRO
   1.117 +!insertmacro un.RemoveDEHRegistrationIfMatching
   1.118 +!endif
   1.119 +!insertmacro un.RemoveQuotesFromPath
   1.120 +!insertmacro un.SetAppLSPCategories
   1.121 +!insertmacro un.SetBrandNameVars
   1.122 +
   1.123 +!include shared.nsh
   1.124 +
   1.125 +; Helper macros for ui callbacks. Insert these after shared.nsh
   1.126 +!insertmacro OnEndCommon
   1.127 +!insertmacro UninstallOnInitCommon
   1.128 +
   1.129 +!insertmacro un.OnEndCommon
   1.130 +!insertmacro un.UninstallUnOnInitCommon
   1.131 +
   1.132 +Name "${BrandFullName}"
   1.133 +OutFile "helper.exe"
   1.134 +!ifdef HAVE_64BIT_OS
   1.135 +  InstallDir "$PROGRAMFILES64\${BrandFullName}\"
   1.136 +!else
   1.137 +  InstallDir "$PROGRAMFILES32\${BrandFullName}\"
   1.138 +!endif
   1.139 +ShowUnInstDetails nevershow
   1.140 +
   1.141 +################################################################################
   1.142 +# Modern User Interface - MUI
   1.143 +
   1.144 +!define MUI_ABORTWARNING
   1.145 +!define MUI_ICON setup.ico
   1.146 +!define MUI_UNICON setup.ico
   1.147 +!define MUI_WELCOMEPAGE_TITLE_3LINES
   1.148 +!define MUI_HEADERIMAGE
   1.149 +!define MUI_HEADERIMAGE_RIGHT
   1.150 +!define MUI_UNWELCOMEFINISHPAGE_BITMAP wizWatermark.bmp
   1.151 +
   1.152 +; Use a right to left header image when the language is right to left
   1.153 +!ifdef ${AB_CD}_rtl
   1.154 +!define MUI_HEADERIMAGE_BITMAP_RTL wizHeaderRTL.bmp
   1.155 +!else
   1.156 +!define MUI_HEADERIMAGE_BITMAP wizHeader.bmp
   1.157 +!endif
   1.158 +
   1.159 +/**
   1.160 + * Uninstall Pages
   1.161 + */
   1.162 +; Welcome Page
   1.163 +!define MUI_PAGE_CUSTOMFUNCTION_PRE un.preWelcome
   1.164 +!define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.leaveWelcome
   1.165 +!insertmacro MUI_UNPAGE_WELCOME
   1.166 +
   1.167 +; Custom Uninstall Confirm Page
   1.168 +UninstPage custom un.preConfirm un.leaveConfirm
   1.169 +
   1.170 +; Remove Files Page
   1.171 +!insertmacro MUI_UNPAGE_INSTFILES
   1.172 +
   1.173 +; Finish Page
   1.174 +
   1.175 +; Don't setup the survey controls, functions, etc. when the application has
   1.176 +; defined NO_UNINSTALL_SURVEY
   1.177 +!ifndef NO_UNINSTALL_SURVEY
   1.178 +!define MUI_PAGE_CUSTOMFUNCTION_PRE un.preFinish
   1.179 +!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
   1.180 +!define MUI_FINISHPAGE_SHOWREADME ""
   1.181 +!define MUI_FINISHPAGE_SHOWREADME_TEXT $(SURVEY_TEXT)
   1.182 +!define MUI_FINISHPAGE_SHOWREADME_FUNCTION un.Survey
   1.183 +!endif
   1.184 +
   1.185 +!insertmacro MUI_UNPAGE_FINISH
   1.186 +
   1.187 +; Use the default dialog for IDD_VERIFY for a simple Banner
   1.188 +ChangeUI IDD_VERIFY "${NSISDIR}\Contrib\UIs\default.exe"
   1.189 +
   1.190 +; This function is used to uninstall the maintenance service if the
   1.191 +; application currently being uninstalled is the last application to use the 
   1.192 +; maintenance service.
   1.193 +Function un.UninstallServiceIfNotUsed
   1.194 +  ; $0 will store if a subkey exists
   1.195 +  ; $1 will store the first subkey if it exists or an empty string if it doesn't
   1.196 +  ; Backup the old values
   1.197 +  Push $0
   1.198 +  Push $1
   1.199 +
   1.200 +  ; The maintenance service always uses the 64-bit registry on x64 systems
   1.201 +  ${If} ${RunningX64}
   1.202 +    SetRegView 64
   1.203 +  ${EndIf}
   1.204 +
   1.205 +  ; Figure out the number of subkeys
   1.206 +  StrCpy $0 0
   1.207 +loop:
   1.208 +  EnumRegKey $1 HKLM "Software\Mozilla\MaintenanceService" $0
   1.209 +  StrCmp $1 "" doneCount
   1.210 +  IntOp $0 $0 + 1
   1.211 +  goto loop
   1.212 +doneCount:
   1.213 +  ; Restore back the registry view
   1.214 +  ${If} ${RunningX64}
   1.215 +    SetRegView lastUsed
   1.216 +  ${EndIf}
   1.217 +  ${If} $0 == 0
   1.218 +    ; Get the path of the maintenance service uninstaller
   1.219 +    ReadRegStr $1 HKLM ${MaintUninstallKey} "UninstallString"
   1.220 +
   1.221 +    ; If the uninstall string does not exist, skip executing it
   1.222 +    StrCmp $1 "" doneUninstall
   1.223 +
   1.224 +    ; $1 is already a quoted string pointing to the install path
   1.225 +    ; so we're already protected against paths with spaces
   1.226 +    nsExec::Exec "$1 /S"
   1.227 +doneUninstall:
   1.228 +  ${EndIf}
   1.229 +
   1.230 +  ; Restore the old value of $1 and $0
   1.231 +  Pop $1
   1.232 +  Pop $0
   1.233 +FunctionEnd
   1.234 +
   1.235 +################################################################################
   1.236 +# Install Sections
   1.237 +; Empty section required for the installer to compile as an uninstaller
   1.238 +Section ""
   1.239 +SectionEnd
   1.240 +
   1.241 +################################################################################
   1.242 +# Uninstall Sections
   1.243 +
   1.244 +Section "Uninstall"
   1.245 +  SetDetailsPrint textonly
   1.246 +  DetailPrint $(STATUS_UNINSTALL_MAIN)
   1.247 +  SetDetailsPrint none
   1.248 +
   1.249 +  ; Delete the app exe to prevent launching the app while we are uninstalling.
   1.250 +  ClearErrors
   1.251 +  ${DeleteFile} "$INSTDIR\${FileMainEXE}"
   1.252 +  ${If} ${Errors}
   1.253 +    ; If the user closed the application it can take several seconds for it to
   1.254 +    ; shut down completely. If the application is being used by another user we
   1.255 +    ; can still delete the files when the system is restarted.
   1.256 +    Sleep 5000
   1.257 +    ${DeleteFile} "$INSTDIR\${FileMainEXE}"
   1.258 +    ClearErrors
   1.259 +  ${EndIf}
   1.260 +
   1.261 +  ; setup the application model id registration value
   1.262 +  ${un.InitHashAppModelId} "$INSTDIR" "Software\Mozilla\${AppName}\TaskBarIDs"
   1.263 +
   1.264 +  SetShellVarContext current  ; Set SHCTX to HKCU
   1.265 +  ${un.RegCleanMain} "Software\Mozilla"
   1.266 +  ${un.RegCleanUninstall}
   1.267 +  ${un.DeleteShortcuts}
   1.268 +
   1.269 +  ; Unregister resources associated with Win7 taskbar jump lists.
   1.270 +  ${If} ${AtLeastWin7}
   1.271 +  ${AndIf} "$AppUserModelID" != ""
   1.272 +    ApplicationID::UninstallJumpLists "$AppUserModelID"
   1.273 +  ${EndIf}
   1.274 +
   1.275 +  ; Remove the updates directory for Vista and above
   1.276 +  ${un.CleanUpdateDirectories} "Mozilla\Firefox" "Mozilla\updates"
   1.277 +
   1.278 +  ; Remove any app model id's stored in the registry for this install path
   1.279 +  DeleteRegValue HKCU "Software\Mozilla\${AppName}\TaskBarIDs" "$INSTDIR"
   1.280 +  DeleteRegValue HKLM "Software\Mozilla\${AppName}\TaskBarIDs" "$INSTDIR"
   1.281 +
   1.282 +  ClearErrors
   1.283 +  WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
   1.284 +  ${If} ${Errors}
   1.285 +    StrCpy $TmpVal "HKCU" ; used primarily for logging
   1.286 +  ${Else}
   1.287 +    SetShellVarContext all  ; Set SHCTX to HKLM
   1.288 +    DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
   1.289 +    StrCpy $TmpVal "HKLM" ; used primarily for logging
   1.290 +    ${un.RegCleanMain} "Software\Mozilla"
   1.291 +    ${un.RegCleanUninstall}
   1.292 +    ${un.DeleteShortcuts}
   1.293 +    ${un.SetAppLSPCategories}
   1.294 +  ${EndIf}
   1.295 +
   1.296 +!ifdef MOZ_METRO
   1.297 +  ${If} ${AtLeastWin8}
   1.298 +    ${un.CleanupMetroBrowserHandlerValues} ${DELEGATE_EXECUTE_HANDLER_ID} \
   1.299 +                                           "FirefoxURL" \
   1.300 +                                           "FirefoxHTML"
   1.301 +  ${EndIf}
   1.302 +  ${ResetWin8PromptKeys} "HKCU" ""
   1.303 +  ${ResetWin8MetroSplash}
   1.304 +!else
   1.305 +  ; The metro browser is not enabled by the mozconfig.
   1.306 +  ${If} ${AtLeastWin8}
   1.307 +    ${RemoveDEHRegistration} ${DELEGATE_EXECUTE_HANDLER_ID} \
   1.308 +                             $AppUserModelID \
   1.309 +                             "FirefoxURL" \
   1.310 +                             "FirefoxHTML"
   1.311 +  ${EndIf}
   1.312 +!endif
   1.313 +
   1.314 +  ${un.RegCleanAppHandler} "FirefoxURL"
   1.315 +  ${un.RegCleanAppHandler} "FirefoxHTML"
   1.316 +  ${un.RegCleanProtocolHandler} "ftp"
   1.317 +  ${un.RegCleanProtocolHandler} "http"
   1.318 +  ${un.RegCleanProtocolHandler} "https"
   1.319 +
   1.320 +  ClearErrors
   1.321 +  ReadRegStr $R9 HKCR "FirefoxHTML" ""
   1.322 +  ; Don't clean up the file handlers if the FirefoxHTML key still exists since
   1.323 +  ; there should be a second installation that may be the default file handler
   1.324 +  ${If} ${Errors}
   1.325 +    ${un.RegCleanFileHandler}  ".htm"   "FirefoxHTML"
   1.326 +    ${un.RegCleanFileHandler}  ".html"  "FirefoxHTML"
   1.327 +    ${un.RegCleanFileHandler}  ".shtml" "FirefoxHTML"
   1.328 +    ${un.RegCleanFileHandler}  ".xht"   "FirefoxHTML"
   1.329 +    ${un.RegCleanFileHandler}  ".xhtml" "FirefoxHTML"
   1.330 +    ${un.RegCleanFileHandler}  ".oga"  "FirefoxHTML"
   1.331 +    ${un.RegCleanFileHandler}  ".ogg"  "FirefoxHTML"
   1.332 +    ${un.RegCleanFileHandler}  ".ogv"  "FirefoxHTML"
   1.333 +    ${un.RegCleanFileHandler}  ".pdf"  "FirefoxHTML"
   1.334 +    ${un.RegCleanFileHandler}  ".webm"  "FirefoxHTML"
   1.335 +  ${EndIf}
   1.336 +
   1.337 +  SetShellVarContext all  ; Set SHCTX to HKLM
   1.338 +  ${un.GetSecondInstallPath} "Software\Mozilla" $R9
   1.339 +  ${If} $R9 == "false"
   1.340 +    SetShellVarContext current  ; Set SHCTX to HKCU
   1.341 +    ${un.GetSecondInstallPath} "Software\Mozilla" $R9
   1.342 +  ${EndIf}
   1.343 +
   1.344 +  StrCpy $0 "Software\Clients\StartMenuInternet\${FileMainEXE}\shell\open\command"
   1.345 +  ReadRegStr $R1 HKLM "$0" ""
   1.346 +  ${un.RemoveQuotesFromPath} "$R1" $R1
   1.347 +  ${un.GetParent} "$R1" $R1
   1.348 +
   1.349 +  ; Only remove the StartMenuInternet key if it refers to this install location.
   1.350 +  ; The StartMenuInternet registry key is independent of the default browser
   1.351 +  ; settings. The XPInstall base un-installer always removes this key if it is
   1.352 +  ; uninstalling the default browser and it will always replace the keys when
   1.353 +  ; installing even if there is another install of Firefox that is set as the
   1.354 +  ; default browser. Now the key is always updated on install but it is only
   1.355 +  ; removed if it refers to this install location.
   1.356 +  ${If} "$INSTDIR" == "$R1"
   1.357 +    DeleteRegKey HKLM "Software\Clients\StartMenuInternet\${FileMainEXE}"
   1.358 +    DeleteRegValue HKLM "Software\RegisteredApplications" "${AppRegName}"
   1.359 +  ${EndIf}
   1.360 +
   1.361 +  ReadRegStr $R1 HKCU "$0" ""
   1.362 +  ${un.RemoveQuotesFromPath} "$R1" $R1
   1.363 +  ${un.GetParent} "$R1" $R1
   1.364 +
   1.365 +  ; Only remove the StartMenuInternet key if it refers to this install location.
   1.366 +  ; The StartMenuInternet registry key is independent of the default browser
   1.367 +  ; settings. The XPInstall base un-installer always removes this key if it is
   1.368 +  ; uninstalling the default browser and it will always replace the keys when
   1.369 +  ; installing even if there is another install of Firefox that is set as the
   1.370 +  ; default browser. Now the key is always updated on install but it is only
   1.371 +  ; removed if it refers to this install location.
   1.372 +  ${If} "$INSTDIR" == "$R1"
   1.373 +    DeleteRegKey HKCU "Software\Clients\StartMenuInternet\${FileMainEXE}"
   1.374 +    DeleteRegValue HKCU "Software\RegisteredApplications" "${AppRegName}"
   1.375 +  ${EndIf}
   1.376 +
   1.377 +  StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\App Paths\${FileMainEXE}"
   1.378 +  ${If} $R9 == "false"
   1.379 +    DeleteRegKey HKLM "$0"
   1.380 +    DeleteRegKey HKCU "$0"
   1.381 +    StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\${FileMainEXE}"
   1.382 +    DeleteRegKey HKLM "$0"
   1.383 +    DeleteRegKey HKCU "$0"
   1.384 +    StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\plugin-container.exe"
   1.385 +    DeleteRegKey HKLM "$0"
   1.386 +    DeleteRegKey HKCU "$0"
   1.387 +    StrCpy $0 "Software\Classes\MIME\Database\Content Type\application/x-xpinstall;app=firefox"
   1.388 +    DeleteRegKey HKLM "$0"
   1.389 +    DeleteRegKey HKCU "$0"
   1.390 +  ${Else}
   1.391 +    ReadRegStr $R1 HKLM "$0" ""
   1.392 +    ${un.RemoveQuotesFromPath} "$R1" $R1
   1.393 +    ${un.GetParent} "$R1" $R1
   1.394 +    ${If} "$INSTDIR" == "$R1"
   1.395 +      WriteRegStr HKLM "$0" "" "$R9"
   1.396 +      ${un.GetParent} "$R9" $R1
   1.397 +      WriteRegStr HKLM "$0" "Path" "$R1"
   1.398 +    ${EndIf}
   1.399 +  ${EndIf}
   1.400 +
   1.401 +  ; Remove directories and files we always control before parsing the uninstall
   1.402 +  ; log so empty directories can be removed.
   1.403 +  ${If} ${FileExists} "$INSTDIR\updates"
   1.404 +    RmDir /r /REBOOTOK "$INSTDIR\updates"
   1.405 +  ${EndIf}
   1.406 +  ${If} ${FileExists} "$INSTDIR\updated"
   1.407 +    RmDir /r /REBOOTOK "$INSTDIR\updated"
   1.408 +  ${EndIf}
   1.409 +  ${If} ${FileExists} "$INSTDIR\defaults\shortcuts"
   1.410 +    RmDir /r /REBOOTOK "$INSTDIR\defaults\shortcuts"
   1.411 +  ${EndIf}
   1.412 +  ${If} ${FileExists} "$INSTDIR\distribution"
   1.413 +    RmDir /r /REBOOTOK "$INSTDIR\distribution"
   1.414 +  ${EndIf}
   1.415 +  ${If} ${FileExists} "$INSTDIR\removed-files"
   1.416 +    Delete /REBOOTOK "$INSTDIR\removed-files"
   1.417 +  ${EndIf}
   1.418 +
   1.419 +  ; Remove files that may be left behind by the application in the
   1.420 +  ; VirtualStore directory.
   1.421 +  ${un.CleanVirtualStore}
   1.422 +
   1.423 +  ; Parse the uninstall log to unregister dll's and remove all installed
   1.424 +  ; files / directories this install is responsible for.
   1.425 +  ${un.ParseUninstallLog}
   1.426 +
   1.427 +  ; Remove the uninstall directory that we control
   1.428 +  RmDir /r /REBOOTOK "$INSTDIR\uninstall"
   1.429 +
   1.430 +  ; Explictly remove empty webapprt dir in case it exists
   1.431 +  ; See bug 757978
   1.432 +  RmDir "$INSTDIR\webapprt\components"
   1.433 +  RmDir "$INSTDIR\webapprt"
   1.434 +
   1.435 +  RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
   1.436 +
   1.437 +  ; Remove the installation directory if it is empty
   1.438 +  ${RemoveDir} "$INSTDIR"
   1.439 +
   1.440 +  ; If firefox.exe was successfully deleted yet we still need to restart to
   1.441 +  ; remove other files create a dummy firefox.exe.moz-delete to prevent the
   1.442 +  ; installer from allowing an install without restart when it is required
   1.443 +  ; to complete an uninstall.
   1.444 +  ${If} ${RebootFlag}
   1.445 +    ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-delete"
   1.446 +      FileOpen $0 "$INSTDIR\${FileMainEXE}.moz-delete" w
   1.447 +      FileWrite $0 "Will be deleted on restart"
   1.448 +      Delete /REBOOTOK "$INSTDIR\${FileMainEXE}.moz-delete"
   1.449 +      FileClose $0
   1.450 +    ${EndUnless}
   1.451 +  ${EndIf}
   1.452 +
   1.453 +  ; Refresh desktop icons otherwise the start menu internet item won't be
   1.454 +  ; removed and other ugly things will happen like recreation of the app's
   1.455 +  ; clients registry key by the OS under some conditions.
   1.456 +  System::Call "shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i 0, i 0, i 0)"
   1.457 +
   1.458 +!ifdef MOZ_MAINTENANCE_SERVICE
   1.459 +  ; Get the path the allowed cert is at and remove it
   1.460 +  ; Keep this block of code last since it modfies the reg view
   1.461 +  ServicesHelper::PathToUniqueRegistryPath "$INSTDIR"
   1.462 +  Pop $MaintCertKey
   1.463 +  ${If} $MaintCertKey != ""
   1.464 +    ; We always use the 64bit registry for certs
   1.465 +    ${If} ${RunningX64}
   1.466 +      SetRegView 64
   1.467 +    ${EndIf}
   1.468 +    DeleteRegKey HKLM "$MaintCertKey"
   1.469 +    ${If} ${RunningX64}
   1.470 +      SetRegView lastused
   1.471 +    ${EndIf}
   1.472 +  ${EndIf}
   1.473 +  Call un.UninstallServiceIfNotUsed
   1.474 +!endif
   1.475 +
   1.476 +SectionEnd
   1.477 +
   1.478 +################################################################################
   1.479 +# Helper Functions
   1.480 +
   1.481 +; Don't setup the survey controls, functions, etc. when the application has
   1.482 +; defined NO_UNINSTALL_SURVEY
   1.483 +!ifndef NO_UNINSTALL_SURVEY
   1.484 +Function un.Survey
   1.485 +  Exec "$\"$TmpVal$\" $\"${SurveyURL}$\""
   1.486 +FunctionEnd
   1.487 +!endif
   1.488 +
   1.489 +################################################################################
   1.490 +# Language
   1.491 +
   1.492 +!insertmacro MOZ_MUI_LANGUAGE 'baseLocale'
   1.493 +!verbose push
   1.494 +!verbose 3
   1.495 +!include "overrideLocale.nsh"
   1.496 +!include "customLocale.nsh"
   1.497 +!verbose pop
   1.498 +
   1.499 +; Set this after the locale files to override it if it is in the locale. Using
   1.500 +; " " for BrandingText will hide the "Nullsoft Install System..." branding.
   1.501 +BrandingText " "
   1.502 +
   1.503 +################################################################################
   1.504 +# Page pre, show, and leave functions
   1.505 +
   1.506 +Function un.preWelcome
   1.507 +  ${If} ${FileExists} "$INSTDIR\distribution\modern-wizard.bmp"
   1.508 +    Delete "$PLUGINSDIR\modern-wizard.bmp"
   1.509 +    CopyFiles /SILENT "$INSTDIR\distribution\modern-wizard.bmp" "$PLUGINSDIR\modern-wizard.bmp"
   1.510 +  ${EndIf}
   1.511 +FunctionEnd
   1.512 +
   1.513 +Function un.leaveWelcome
   1.514 +  ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
   1.515 +    Banner::show /NOUNLOAD "$(BANNER_CHECK_EXISTING)"
   1.516 +
   1.517 +    ; If the message window has been found previously give the app an additional
   1.518 +    ; five seconds to close.
   1.519 +    ${If} "$TmpVal" == "FoundMessageWindow"
   1.520 +      Sleep 5000
   1.521 +    ${EndIf}
   1.522 +
   1.523 +    ${PushFilesToCheck}
   1.524 +
   1.525 +    ${un.CheckForFilesInUse} $TmpVal
   1.526 +
   1.527 +    Banner::destroy
   1.528 +
   1.529 +    ; If there are files in use $TmpVal will be "true"
   1.530 +    ${If} "$TmpVal" == "true"
   1.531 +      ; If the message window is found the call to ManualCloseAppPrompt will
   1.532 +      ; abort leaving the value of $TmpVal set to "FoundMessageWindow".
   1.533 +      StrCpy $TmpVal "FoundMessageWindow"
   1.534 +      ${un.ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_UNINSTALL)"
   1.535 +      ; If the message window is not found set $TmpVal to "true" so the restart
   1.536 +      ; required message is displayed.
   1.537 +      StrCpy $TmpVal "true"
   1.538 +    ${EndIf}
   1.539 +  ${EndIf}
   1.540 +FunctionEnd
   1.541 +
   1.542 +Function un.preConfirm
   1.543 +  ${If} ${FileExists} "$INSTDIR\distribution\modern-header.bmp"
   1.544 +  ${AndIf} $hHeaderBitmap == ""
   1.545 +    Delete "$PLUGINSDIR\modern-header.bmp"
   1.546 +    CopyFiles /SILENT "$INSTDIR\distribution\modern-header.bmp" "$PLUGINSDIR\modern-header.bmp"
   1.547 +    ${un.ChangeMUIHeaderImage} "$PLUGINSDIR\modern-header.bmp"
   1.548 +  ${EndIf}
   1.549 +
   1.550 +  ; Setup the unconfirm.ini file for the Custom Uninstall Confirm Page
   1.551 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Settings" NumFields "3"
   1.552 +
   1.553 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Type   "label"
   1.554 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Text   "$(UN_CONFIRM_UNINSTALLED_FROM)"
   1.555 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Left   "0"
   1.556 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Right  "-1"
   1.557 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Top    "5"
   1.558 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Bottom "15"
   1.559 +
   1.560 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Type   "text"
   1.561 +  ; The contents of this control must be set as follows in the pre function
   1.562 +  ; ${MUI_INSTALLOPTIONS_READ} $1 "unconfirm.ini" "Field 2" "HWND"
   1.563 +  ; SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
   1.564 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" State  ""
   1.565 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Left   "0"
   1.566 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Right  "-1"
   1.567 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Top    "17"
   1.568 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Bottom "30"
   1.569 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" flags  "READONLY"
   1.570 +
   1.571 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Type   "label"
   1.572 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Text   "$(UN_CONFIRM_CLICK)"
   1.573 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Left   "0"
   1.574 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Right  "-1"
   1.575 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Top    "130"
   1.576 +  WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Bottom "150"
   1.577 +
   1.578 +  ${If} "$TmpVal" == "true"
   1.579 +    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Type   "label"
   1.580 +    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Text   "$(SUMMARY_REBOOT_REQUIRED_UNINSTALL)"
   1.581 +    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Left   "0"
   1.582 +    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Right  "-1"
   1.583 +    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Top    "35"
   1.584 +    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Bottom "45"
   1.585 +
   1.586 +    WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Settings" NumFields "4"
   1.587 +  ${EndIf}
   1.588 +
   1.589 +  !insertmacro MUI_HEADER_TEXT "$(UN_CONFIRM_PAGE_TITLE)" "$(UN_CONFIRM_PAGE_SUBTITLE)"
   1.590 +  ; The Summary custom page has a textbox that will automatically receive
   1.591 +  ; focus. This sets the focus to the Install button instead.
   1.592 +  !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "unconfirm.ini"
   1.593 +  GetDlgItem $0 $HWNDPARENT 1
   1.594 +  System::Call "user32::SetFocus(i r0, i 0x0007, i,i)i"
   1.595 +  ${MUI_INSTALLOPTIONS_READ} $1 "unconfirm.ini" "Field 2" "HWND"
   1.596 +  SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
   1.597 +  !insertmacro MUI_INSTALLOPTIONS_SHOW
   1.598 +FunctionEnd
   1.599 +
   1.600 +Function un.leaveConfirm
   1.601 +  ; Try to delete the app executable and if we can't delete it try to find the
   1.602 +  ; app's message window and prompt the user to close the app. This allows
   1.603 +  ; running an instance that is located in another directory. If for whatever
   1.604 +  ; reason there is no message window we will just rename the app's files and
   1.605 +  ; then remove them on restart if they are in use.
   1.606 +  ClearErrors
   1.607 +  ${DeleteFile} "$INSTDIR\${FileMainEXE}"
   1.608 +  ${If} ${Errors}
   1.609 +    ${un.ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_UNINSTALL)"
   1.610 +  ${EndIf}
   1.611 +FunctionEnd
   1.612 +
   1.613 +!ifndef NO_UNINSTALL_SURVEY
   1.614 +Function un.preFinish
   1.615 +  ; Do not modify the finish page if there is a reboot pending
   1.616 +  ${Unless} ${RebootFlag}
   1.617 +    ; Setup the survey controls, functions, etc.
   1.618 +    StrCpy $TmpVal "SOFTWARE\Microsoft\IE Setup\Setup"
   1.619 +    ClearErrors
   1.620 +    ReadRegStr $0 HKLM $TmpVal "Path"
   1.621 +    ${If} ${Errors}
   1.622 +      !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "NumFields" "3"
   1.623 +    ${Else}
   1.624 +      ExpandEnvStrings $0 "$0" ; this value will usually contain %programfiles%
   1.625 +      ${If} $0 != "\"
   1.626 +        StrCpy $0 "$0\"
   1.627 +      ${EndIf}
   1.628 +      StrCpy $0 "$0\iexplore.exe"
   1.629 +      ClearErrors
   1.630 +      GetFullPathName $TmpVal $0
   1.631 +      ${If} ${Errors}
   1.632 +        !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "NumFields" "3"
   1.633 +      ${Else}
   1.634 +        ; When we add an optional action to the finish page the cancel button
   1.635 +        ; is enabled. This disables it and leaves the finish button as the
   1.636 +        ; only choice.
   1.637 +        !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "cancelenabled" "0"
   1.638 +      ${EndIf}
   1.639 +    ${EndIf}
   1.640 +  ${EndUnless}
   1.641 +FunctionEnd
   1.642 +!endif
   1.643 +
   1.644 +################################################################################
   1.645 +# Initialization Functions
   1.646 +
   1.647 +Function .onInit
   1.648 +  ; Remove the current exe directory from the search order.
   1.649 +  ; This only effects LoadLibrary calls and not implicitly loaded DLLs.
   1.650 +  System::Call 'kernel32::SetDllDirectoryW(w "")'
   1.651 +
   1.652 +  ; We need this set up for most of the helper.exe operations.
   1.653 +  ${UninstallOnInitCommon}
   1.654 +FunctionEnd
   1.655 +
   1.656 +Function un.onInit
   1.657 +  ; Remove the current exe directory from the search order.
   1.658 +  ; This only effects LoadLibrary calls and not implicitly loaded DLLs.
   1.659 +  System::Call 'kernel32::SetDllDirectoryW(w "")'
   1.660 +
   1.661 +  StrCpy $LANGUAGE 0
   1.662 +
   1.663 +  ${un.UninstallUnOnInitCommon}
   1.664 +
   1.665 +; The commands inside this ifndef are needed prior to NSIS 3.0a2 and can be
   1.666 +; removed after we require NSIS 3.0a2 or greater.
   1.667 +!ifndef NSIS_PACKEDVERSION
   1.668 +  ${If} ${AtLeastWinVista}
   1.669 +    System::Call 'user32::SetProcessDPIAware()'
   1.670 +  ${EndIf}
   1.671 +!endif
   1.672 +
   1.673 +  !insertmacro InitInstallOptionsFile "unconfirm.ini"
   1.674 +FunctionEnd
   1.675 +
   1.676 +Function .onGUIEnd
   1.677 +  ${OnEndCommon}
   1.678 +FunctionEnd
   1.679 +
   1.680 +Function un.onGUIEnd
   1.681 +  ${un.OnEndCommon}
   1.682 +FunctionEnd

mercurial