browser/installer/windows/nsis/uninstaller.nsi

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4
michael@0 5 # Required Plugins:
michael@0 6 # AppAssocReg http://nsis.sourceforge.net/Application_Association_Registration_plug-in
michael@0 7 # CityHash http://mxr.mozilla.org/mozilla-central/source/other-licenses/nsis/Contrib/CityHash
michael@0 8 # ShellLink http://nsis.sourceforge.net/ShellLink_plug-in
michael@0 9 # UAC http://nsis.sourceforge.net/UAC_plug-in
michael@0 10
michael@0 11 ; Set verbosity to 3 (e.g. no script) to lessen the noise in the build logs
michael@0 12 !verbose 3
michael@0 13
michael@0 14 ; 7-Zip provides better compression than the lzma from NSIS so we add the files
michael@0 15 ; uncompressed and use 7-Zip to create a SFX archive of it
michael@0 16 SetDatablockOptimize on
michael@0 17 SetCompress off
michael@0 18 CRCCheck on
michael@0 19
michael@0 20 RequestExecutionLevel user
michael@0 21
michael@0 22 ; The commands inside this ifdef require NSIS 3.0a2 or greater so the ifdef can
michael@0 23 ; be removed after we require NSIS 3.0a2 or greater.
michael@0 24 !ifdef NSIS_PACKEDVERSION
michael@0 25 Unicode true
michael@0 26 ManifestSupportedOS all
michael@0 27 ManifestDPIAware true
michael@0 28 !endif
michael@0 29
michael@0 30 !addplugindir ./
michael@0 31
michael@0 32 ; On Vista and above attempt to elevate Standard Users in addition to users that
michael@0 33 ; are a member of the Administrators group.
michael@0 34 !define NONADMIN_ELEVATE
michael@0 35
michael@0 36 ; prevents compiling of the reg write logging.
michael@0 37 !define NO_LOG
michael@0 38
michael@0 39 !define MaintUninstallKey \
michael@0 40 "Software\Microsoft\Windows\CurrentVersion\Uninstall\MozillaMaintenanceService"
michael@0 41
michael@0 42 Var TmpVal
michael@0 43 Var MaintCertKey
michael@0 44
michael@0 45 ; Other included files may depend upon these includes!
michael@0 46 ; The following includes are provided by NSIS.
michael@0 47 !include FileFunc.nsh
michael@0 48 !include LogicLib.nsh
michael@0 49 !include MUI.nsh
michael@0 50 !include WinMessages.nsh
michael@0 51 !include WinVer.nsh
michael@0 52 !include WordFunc.nsh
michael@0 53
michael@0 54 !insertmacro GetSize
michael@0 55 !insertmacro StrFilter
michael@0 56 !insertmacro WordReplace
michael@0 57
michael@0 58 !insertmacro un.GetParent
michael@0 59
michael@0 60 ; The following includes are custom.
michael@0 61 !include branding.nsi
michael@0 62 !include defines.nsi
michael@0 63 !include common.nsh
michael@0 64 !include locales.nsi
michael@0 65
michael@0 66 ; This is named BrandShortName helper because we use this for software update
michael@0 67 ; post update cleanup.
michael@0 68 VIAddVersionKey "FileDescription" "${BrandShortName} Helper"
michael@0 69 VIAddVersionKey "OriginalFilename" "helper.exe"
michael@0 70
michael@0 71 !insertmacro AddDisabledDDEHandlerValues
michael@0 72 !insertmacro CleanVirtualStore
michael@0 73 !insertmacro ElevateUAC
michael@0 74 !insertmacro GetLongPath
michael@0 75 !insertmacro GetPathFromString
michael@0 76 !insertmacro InitHashAppModelId
michael@0 77 !insertmacro IsHandlerForInstallDir
michael@0 78 !insertmacro IsPinnedToTaskBar
michael@0 79 !insertmacro IsUserAdmin
michael@0 80 !insertmacro LogDesktopShortcut
michael@0 81 !insertmacro LogQuickLaunchShortcut
michael@0 82 !insertmacro LogStartMenuShortcut
michael@0 83 !insertmacro PinnedToStartMenuLnkCount
michael@0 84 !insertmacro RegCleanAppHandler
michael@0 85 !insertmacro RegCleanMain
michael@0 86 !insertmacro RegCleanUninstall
michael@0 87 !ifdef MOZ_METRO
michael@0 88 !insertmacro RemoveDEHRegistrationIfMatching
michael@0 89 !endif
michael@0 90 !insertmacro SetAppLSPCategories
michael@0 91 !insertmacro SetBrandNameVars
michael@0 92 !insertmacro UpdateShortcutAppModelIDs
michael@0 93 !insertmacro UnloadUAC
michael@0 94 !insertmacro WriteRegDWORD2
michael@0 95 !insertmacro WriteRegStr2
michael@0 96 !insertmacro CheckIfRegistryKeyExists
michael@0 97
michael@0 98 !insertmacro un.ChangeMUIHeaderImage
michael@0 99 !insertmacro un.CheckForFilesInUse
michael@0 100 !insertmacro un.CleanUpdateDirectories
michael@0 101 !insertmacro un.CleanVirtualStore
michael@0 102 !insertmacro un.DeleteShortcuts
michael@0 103 !insertmacro un.GetLongPath
michael@0 104 !insertmacro un.GetSecondInstallPath
michael@0 105 !insertmacro un.InitHashAppModelId
michael@0 106 !insertmacro un.ManualCloseAppPrompt
michael@0 107 !insertmacro un.ParseUninstallLog
michael@0 108 !insertmacro un.RegCleanAppHandler
michael@0 109 !insertmacro un.RegCleanFileHandler
michael@0 110 !insertmacro un.RegCleanMain
michael@0 111 !insertmacro un.RegCleanUninstall
michael@0 112 !insertmacro un.RegCleanProtocolHandler
michael@0 113 !ifdef MOZ_METRO
michael@0 114 !insertmacro un.RemoveDEHRegistrationIfMatching
michael@0 115 !endif
michael@0 116 !insertmacro un.RemoveQuotesFromPath
michael@0 117 !insertmacro un.SetAppLSPCategories
michael@0 118 !insertmacro un.SetBrandNameVars
michael@0 119
michael@0 120 !include shared.nsh
michael@0 121
michael@0 122 ; Helper macros for ui callbacks. Insert these after shared.nsh
michael@0 123 !insertmacro OnEndCommon
michael@0 124 !insertmacro UninstallOnInitCommon
michael@0 125
michael@0 126 !insertmacro un.OnEndCommon
michael@0 127 !insertmacro un.UninstallUnOnInitCommon
michael@0 128
michael@0 129 Name "${BrandFullName}"
michael@0 130 OutFile "helper.exe"
michael@0 131 !ifdef HAVE_64BIT_OS
michael@0 132 InstallDir "$PROGRAMFILES64\${BrandFullName}\"
michael@0 133 !else
michael@0 134 InstallDir "$PROGRAMFILES32\${BrandFullName}\"
michael@0 135 !endif
michael@0 136 ShowUnInstDetails nevershow
michael@0 137
michael@0 138 ################################################################################
michael@0 139 # Modern User Interface - MUI
michael@0 140
michael@0 141 !define MUI_ABORTWARNING
michael@0 142 !define MUI_ICON setup.ico
michael@0 143 !define MUI_UNICON setup.ico
michael@0 144 !define MUI_WELCOMEPAGE_TITLE_3LINES
michael@0 145 !define MUI_HEADERIMAGE
michael@0 146 !define MUI_HEADERIMAGE_RIGHT
michael@0 147 !define MUI_UNWELCOMEFINISHPAGE_BITMAP wizWatermark.bmp
michael@0 148
michael@0 149 ; Use a right to left header image when the language is right to left
michael@0 150 !ifdef ${AB_CD}_rtl
michael@0 151 !define MUI_HEADERIMAGE_BITMAP_RTL wizHeaderRTL.bmp
michael@0 152 !else
michael@0 153 !define MUI_HEADERIMAGE_BITMAP wizHeader.bmp
michael@0 154 !endif
michael@0 155
michael@0 156 /**
michael@0 157 * Uninstall Pages
michael@0 158 */
michael@0 159 ; Welcome Page
michael@0 160 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.preWelcome
michael@0 161 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE un.leaveWelcome
michael@0 162 !insertmacro MUI_UNPAGE_WELCOME
michael@0 163
michael@0 164 ; Custom Uninstall Confirm Page
michael@0 165 UninstPage custom un.preConfirm un.leaveConfirm
michael@0 166
michael@0 167 ; Remove Files Page
michael@0 168 !insertmacro MUI_UNPAGE_INSTFILES
michael@0 169
michael@0 170 ; Finish Page
michael@0 171
michael@0 172 ; Don't setup the survey controls, functions, etc. when the application has
michael@0 173 ; defined NO_UNINSTALL_SURVEY
michael@0 174 !ifndef NO_UNINSTALL_SURVEY
michael@0 175 !define MUI_PAGE_CUSTOMFUNCTION_PRE un.preFinish
michael@0 176 !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
michael@0 177 !define MUI_FINISHPAGE_SHOWREADME ""
michael@0 178 !define MUI_FINISHPAGE_SHOWREADME_TEXT $(SURVEY_TEXT)
michael@0 179 !define MUI_FINISHPAGE_SHOWREADME_FUNCTION un.Survey
michael@0 180 !endif
michael@0 181
michael@0 182 !insertmacro MUI_UNPAGE_FINISH
michael@0 183
michael@0 184 ; Use the default dialog for IDD_VERIFY for a simple Banner
michael@0 185 ChangeUI IDD_VERIFY "${NSISDIR}\Contrib\UIs\default.exe"
michael@0 186
michael@0 187 ; This function is used to uninstall the maintenance service if the
michael@0 188 ; application currently being uninstalled is the last application to use the
michael@0 189 ; maintenance service.
michael@0 190 Function un.UninstallServiceIfNotUsed
michael@0 191 ; $0 will store if a subkey exists
michael@0 192 ; $1 will store the first subkey if it exists or an empty string if it doesn't
michael@0 193 ; Backup the old values
michael@0 194 Push $0
michael@0 195 Push $1
michael@0 196
michael@0 197 ; The maintenance service always uses the 64-bit registry on x64 systems
michael@0 198 ${If} ${RunningX64}
michael@0 199 SetRegView 64
michael@0 200 ${EndIf}
michael@0 201
michael@0 202 ; Figure out the number of subkeys
michael@0 203 StrCpy $0 0
michael@0 204 loop:
michael@0 205 EnumRegKey $1 HKLM "Software\Mozilla\MaintenanceService" $0
michael@0 206 StrCmp $1 "" doneCount
michael@0 207 IntOp $0 $0 + 1
michael@0 208 goto loop
michael@0 209 doneCount:
michael@0 210 ; Restore back the registry view
michael@0 211 ${If} ${RunningX64}
michael@0 212 SetRegView lastUsed
michael@0 213 ${EndIf}
michael@0 214 ${If} $0 == 0
michael@0 215 ; Get the path of the maintenance service uninstaller
michael@0 216 ReadRegStr $1 HKLM ${MaintUninstallKey} "UninstallString"
michael@0 217
michael@0 218 ; If the uninstall string does not exist, skip executing it
michael@0 219 StrCmp $1 "" doneUninstall
michael@0 220
michael@0 221 ; $1 is already a quoted string pointing to the install path
michael@0 222 ; so we're already protected against paths with spaces
michael@0 223 nsExec::Exec "$1 /S"
michael@0 224 doneUninstall:
michael@0 225 ${EndIf}
michael@0 226
michael@0 227 ; Restore the old value of $1 and $0
michael@0 228 Pop $1
michael@0 229 Pop $0
michael@0 230 FunctionEnd
michael@0 231
michael@0 232 ################################################################################
michael@0 233 # Install Sections
michael@0 234 ; Empty section required for the installer to compile as an uninstaller
michael@0 235 Section ""
michael@0 236 SectionEnd
michael@0 237
michael@0 238 ################################################################################
michael@0 239 # Uninstall Sections
michael@0 240
michael@0 241 Section "Uninstall"
michael@0 242 SetDetailsPrint textonly
michael@0 243 DetailPrint $(STATUS_UNINSTALL_MAIN)
michael@0 244 SetDetailsPrint none
michael@0 245
michael@0 246 ; Delete the app exe to prevent launching the app while we are uninstalling.
michael@0 247 ClearErrors
michael@0 248 ${DeleteFile} "$INSTDIR\${FileMainEXE}"
michael@0 249 ${If} ${Errors}
michael@0 250 ; If the user closed the application it can take several seconds for it to
michael@0 251 ; shut down completely. If the application is being used by another user we
michael@0 252 ; can still delete the files when the system is restarted.
michael@0 253 Sleep 5000
michael@0 254 ${DeleteFile} "$INSTDIR\${FileMainEXE}"
michael@0 255 ClearErrors
michael@0 256 ${EndIf}
michael@0 257
michael@0 258 ; setup the application model id registration value
michael@0 259 ${un.InitHashAppModelId} "$INSTDIR" "Software\Mozilla\${AppName}\TaskBarIDs"
michael@0 260
michael@0 261 SetShellVarContext current ; Set SHCTX to HKCU
michael@0 262 ${un.RegCleanMain} "Software\Mozilla"
michael@0 263 ${un.RegCleanUninstall}
michael@0 264 ${un.DeleteShortcuts}
michael@0 265
michael@0 266 ; Unregister resources associated with Win7 taskbar jump lists.
michael@0 267 ${If} ${AtLeastWin7}
michael@0 268 ${AndIf} "$AppUserModelID" != ""
michael@0 269 ApplicationID::UninstallJumpLists "$AppUserModelID"
michael@0 270 ${EndIf}
michael@0 271
michael@0 272 ; Remove the updates directory for Vista and above
michael@0 273 ${un.CleanUpdateDirectories} "Mozilla\Firefox" "Mozilla\updates"
michael@0 274
michael@0 275 ; Remove any app model id's stored in the registry for this install path
michael@0 276 DeleteRegValue HKCU "Software\Mozilla\${AppName}\TaskBarIDs" "$INSTDIR"
michael@0 277 DeleteRegValue HKLM "Software\Mozilla\${AppName}\TaskBarIDs" "$INSTDIR"
michael@0 278
michael@0 279 ClearErrors
michael@0 280 WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
michael@0 281 ${If} ${Errors}
michael@0 282 StrCpy $TmpVal "HKCU" ; used primarily for logging
michael@0 283 ${Else}
michael@0 284 SetShellVarContext all ; Set SHCTX to HKLM
michael@0 285 DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
michael@0 286 StrCpy $TmpVal "HKLM" ; used primarily for logging
michael@0 287 ${un.RegCleanMain} "Software\Mozilla"
michael@0 288 ${un.RegCleanUninstall}
michael@0 289 ${un.DeleteShortcuts}
michael@0 290 ${un.SetAppLSPCategories}
michael@0 291 ${EndIf}
michael@0 292
michael@0 293 !ifdef MOZ_METRO
michael@0 294 ${If} ${AtLeastWin8}
michael@0 295 ${un.CleanupMetroBrowserHandlerValues} ${DELEGATE_EXECUTE_HANDLER_ID} \
michael@0 296 "FirefoxURL" \
michael@0 297 "FirefoxHTML"
michael@0 298 ${EndIf}
michael@0 299 ${ResetWin8PromptKeys} "HKCU" ""
michael@0 300 ${ResetWin8MetroSplash}
michael@0 301 !else
michael@0 302 ; The metro browser is not enabled by the mozconfig.
michael@0 303 ${If} ${AtLeastWin8}
michael@0 304 ${RemoveDEHRegistration} ${DELEGATE_EXECUTE_HANDLER_ID} \
michael@0 305 $AppUserModelID \
michael@0 306 "FirefoxURL" \
michael@0 307 "FirefoxHTML"
michael@0 308 ${EndIf}
michael@0 309 !endif
michael@0 310
michael@0 311 ${un.RegCleanAppHandler} "FirefoxURL"
michael@0 312 ${un.RegCleanAppHandler} "FirefoxHTML"
michael@0 313 ${un.RegCleanProtocolHandler} "ftp"
michael@0 314 ${un.RegCleanProtocolHandler} "http"
michael@0 315 ${un.RegCleanProtocolHandler} "https"
michael@0 316
michael@0 317 ClearErrors
michael@0 318 ReadRegStr $R9 HKCR "FirefoxHTML" ""
michael@0 319 ; Don't clean up the file handlers if the FirefoxHTML key still exists since
michael@0 320 ; there should be a second installation that may be the default file handler
michael@0 321 ${If} ${Errors}
michael@0 322 ${un.RegCleanFileHandler} ".htm" "FirefoxHTML"
michael@0 323 ${un.RegCleanFileHandler} ".html" "FirefoxHTML"
michael@0 324 ${un.RegCleanFileHandler} ".shtml" "FirefoxHTML"
michael@0 325 ${un.RegCleanFileHandler} ".xht" "FirefoxHTML"
michael@0 326 ${un.RegCleanFileHandler} ".xhtml" "FirefoxHTML"
michael@0 327 ${un.RegCleanFileHandler} ".oga" "FirefoxHTML"
michael@0 328 ${un.RegCleanFileHandler} ".ogg" "FirefoxHTML"
michael@0 329 ${un.RegCleanFileHandler} ".ogv" "FirefoxHTML"
michael@0 330 ${un.RegCleanFileHandler} ".pdf" "FirefoxHTML"
michael@0 331 ${un.RegCleanFileHandler} ".webm" "FirefoxHTML"
michael@0 332 ${EndIf}
michael@0 333
michael@0 334 SetShellVarContext all ; Set SHCTX to HKLM
michael@0 335 ${un.GetSecondInstallPath} "Software\Mozilla" $R9
michael@0 336 ${If} $R9 == "false"
michael@0 337 SetShellVarContext current ; Set SHCTX to HKCU
michael@0 338 ${un.GetSecondInstallPath} "Software\Mozilla" $R9
michael@0 339 ${EndIf}
michael@0 340
michael@0 341 StrCpy $0 "Software\Clients\StartMenuInternet\${FileMainEXE}\shell\open\command"
michael@0 342 ReadRegStr $R1 HKLM "$0" ""
michael@0 343 ${un.RemoveQuotesFromPath} "$R1" $R1
michael@0 344 ${un.GetParent} "$R1" $R1
michael@0 345
michael@0 346 ; Only remove the StartMenuInternet key if it refers to this install location.
michael@0 347 ; The StartMenuInternet registry key is independent of the default browser
michael@0 348 ; settings. The XPInstall base un-installer always removes this key if it is
michael@0 349 ; uninstalling the default browser and it will always replace the keys when
michael@0 350 ; installing even if there is another install of Firefox that is set as the
michael@0 351 ; default browser. Now the key is always updated on install but it is only
michael@0 352 ; removed if it refers to this install location.
michael@0 353 ${If} "$INSTDIR" == "$R1"
michael@0 354 DeleteRegKey HKLM "Software\Clients\StartMenuInternet\${FileMainEXE}"
michael@0 355 DeleteRegValue HKLM "Software\RegisteredApplications" "${AppRegName}"
michael@0 356 ${EndIf}
michael@0 357
michael@0 358 ReadRegStr $R1 HKCU "$0" ""
michael@0 359 ${un.RemoveQuotesFromPath} "$R1" $R1
michael@0 360 ${un.GetParent} "$R1" $R1
michael@0 361
michael@0 362 ; Only remove the StartMenuInternet key if it refers to this install location.
michael@0 363 ; The StartMenuInternet registry key is independent of the default browser
michael@0 364 ; settings. The XPInstall base un-installer always removes this key if it is
michael@0 365 ; uninstalling the default browser and it will always replace the keys when
michael@0 366 ; installing even if there is another install of Firefox that is set as the
michael@0 367 ; default browser. Now the key is always updated on install but it is only
michael@0 368 ; removed if it refers to this install location.
michael@0 369 ${If} "$INSTDIR" == "$R1"
michael@0 370 DeleteRegKey HKCU "Software\Clients\StartMenuInternet\${FileMainEXE}"
michael@0 371 DeleteRegValue HKCU "Software\RegisteredApplications" "${AppRegName}"
michael@0 372 ${EndIf}
michael@0 373
michael@0 374 StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\App Paths\${FileMainEXE}"
michael@0 375 ${If} $R9 == "false"
michael@0 376 DeleteRegKey HKLM "$0"
michael@0 377 DeleteRegKey HKCU "$0"
michael@0 378 StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\${FileMainEXE}"
michael@0 379 DeleteRegKey HKLM "$0"
michael@0 380 DeleteRegKey HKCU "$0"
michael@0 381 StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\plugin-container.exe"
michael@0 382 DeleteRegKey HKLM "$0"
michael@0 383 DeleteRegKey HKCU "$0"
michael@0 384 StrCpy $0 "Software\Classes\MIME\Database\Content Type\application/x-xpinstall;app=firefox"
michael@0 385 DeleteRegKey HKLM "$0"
michael@0 386 DeleteRegKey HKCU "$0"
michael@0 387 ${Else}
michael@0 388 ReadRegStr $R1 HKLM "$0" ""
michael@0 389 ${un.RemoveQuotesFromPath} "$R1" $R1
michael@0 390 ${un.GetParent} "$R1" $R1
michael@0 391 ${If} "$INSTDIR" == "$R1"
michael@0 392 WriteRegStr HKLM "$0" "" "$R9"
michael@0 393 ${un.GetParent} "$R9" $R1
michael@0 394 WriteRegStr HKLM "$0" "Path" "$R1"
michael@0 395 ${EndIf}
michael@0 396 ${EndIf}
michael@0 397
michael@0 398 ; Remove directories and files we always control before parsing the uninstall
michael@0 399 ; log so empty directories can be removed.
michael@0 400 ${If} ${FileExists} "$INSTDIR\updates"
michael@0 401 RmDir /r /REBOOTOK "$INSTDIR\updates"
michael@0 402 ${EndIf}
michael@0 403 ${If} ${FileExists} "$INSTDIR\updated"
michael@0 404 RmDir /r /REBOOTOK "$INSTDIR\updated"
michael@0 405 ${EndIf}
michael@0 406 ${If} ${FileExists} "$INSTDIR\defaults\shortcuts"
michael@0 407 RmDir /r /REBOOTOK "$INSTDIR\defaults\shortcuts"
michael@0 408 ${EndIf}
michael@0 409 ${If} ${FileExists} "$INSTDIR\distribution"
michael@0 410 RmDir /r /REBOOTOK "$INSTDIR\distribution"
michael@0 411 ${EndIf}
michael@0 412 ${If} ${FileExists} "$INSTDIR\removed-files"
michael@0 413 Delete /REBOOTOK "$INSTDIR\removed-files"
michael@0 414 ${EndIf}
michael@0 415
michael@0 416 ; Remove files that may be left behind by the application in the
michael@0 417 ; VirtualStore directory.
michael@0 418 ${un.CleanVirtualStore}
michael@0 419
michael@0 420 ; Parse the uninstall log to unregister dll's and remove all installed
michael@0 421 ; files / directories this install is responsible for.
michael@0 422 ${un.ParseUninstallLog}
michael@0 423
michael@0 424 ; Remove the uninstall directory that we control
michael@0 425 RmDir /r /REBOOTOK "$INSTDIR\uninstall"
michael@0 426
michael@0 427 ; Explictly remove empty webapprt dir in case it exists
michael@0 428 ; See bug 757978
michael@0 429 RmDir "$INSTDIR\webapprt\components"
michael@0 430 RmDir "$INSTDIR\webapprt"
michael@0 431
michael@0 432 RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
michael@0 433
michael@0 434 ; Remove the installation directory if it is empty
michael@0 435 ${RemoveDir} "$INSTDIR"
michael@0 436
michael@0 437 ; If firefox.exe was successfully deleted yet we still need to restart to
michael@0 438 ; remove other files create a dummy firefox.exe.moz-delete to prevent the
michael@0 439 ; installer from allowing an install without restart when it is required
michael@0 440 ; to complete an uninstall.
michael@0 441 ${If} ${RebootFlag}
michael@0 442 ${Unless} ${FileExists} "$INSTDIR\${FileMainEXE}.moz-delete"
michael@0 443 FileOpen $0 "$INSTDIR\${FileMainEXE}.moz-delete" w
michael@0 444 FileWrite $0 "Will be deleted on restart"
michael@0 445 Delete /REBOOTOK "$INSTDIR\${FileMainEXE}.moz-delete"
michael@0 446 FileClose $0
michael@0 447 ${EndUnless}
michael@0 448 ${EndIf}
michael@0 449
michael@0 450 ; Refresh desktop icons otherwise the start menu internet item won't be
michael@0 451 ; removed and other ugly things will happen like recreation of the app's
michael@0 452 ; clients registry key by the OS under some conditions.
michael@0 453 System::Call "shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i 0, i 0, i 0)"
michael@0 454
michael@0 455 !ifdef MOZ_MAINTENANCE_SERVICE
michael@0 456 ; Get the path the allowed cert is at and remove it
michael@0 457 ; Keep this block of code last since it modfies the reg view
michael@0 458 ServicesHelper::PathToUniqueRegistryPath "$INSTDIR"
michael@0 459 Pop $MaintCertKey
michael@0 460 ${If} $MaintCertKey != ""
michael@0 461 ; We always use the 64bit registry for certs
michael@0 462 ${If} ${RunningX64}
michael@0 463 SetRegView 64
michael@0 464 ${EndIf}
michael@0 465 DeleteRegKey HKLM "$MaintCertKey"
michael@0 466 ${If} ${RunningX64}
michael@0 467 SetRegView lastused
michael@0 468 ${EndIf}
michael@0 469 ${EndIf}
michael@0 470 Call un.UninstallServiceIfNotUsed
michael@0 471 !endif
michael@0 472
michael@0 473 SectionEnd
michael@0 474
michael@0 475 ################################################################################
michael@0 476 # Helper Functions
michael@0 477
michael@0 478 ; Don't setup the survey controls, functions, etc. when the application has
michael@0 479 ; defined NO_UNINSTALL_SURVEY
michael@0 480 !ifndef NO_UNINSTALL_SURVEY
michael@0 481 Function un.Survey
michael@0 482 Exec "$\"$TmpVal$\" $\"${SurveyURL}$\""
michael@0 483 FunctionEnd
michael@0 484 !endif
michael@0 485
michael@0 486 ################################################################################
michael@0 487 # Language
michael@0 488
michael@0 489 !insertmacro MOZ_MUI_LANGUAGE 'baseLocale'
michael@0 490 !verbose push
michael@0 491 !verbose 3
michael@0 492 !include "overrideLocale.nsh"
michael@0 493 !include "customLocale.nsh"
michael@0 494 !verbose pop
michael@0 495
michael@0 496 ; Set this after the locale files to override it if it is in the locale. Using
michael@0 497 ; " " for BrandingText will hide the "Nullsoft Install System..." branding.
michael@0 498 BrandingText " "
michael@0 499
michael@0 500 ################################################################################
michael@0 501 # Page pre, show, and leave functions
michael@0 502
michael@0 503 Function un.preWelcome
michael@0 504 ${If} ${FileExists} "$INSTDIR\distribution\modern-wizard.bmp"
michael@0 505 Delete "$PLUGINSDIR\modern-wizard.bmp"
michael@0 506 CopyFiles /SILENT "$INSTDIR\distribution\modern-wizard.bmp" "$PLUGINSDIR\modern-wizard.bmp"
michael@0 507 ${EndIf}
michael@0 508 FunctionEnd
michael@0 509
michael@0 510 Function un.leaveWelcome
michael@0 511 ${If} ${FileExists} "$INSTDIR\${FileMainEXE}"
michael@0 512 Banner::show /NOUNLOAD "$(BANNER_CHECK_EXISTING)"
michael@0 513
michael@0 514 ; If the message window has been found previously give the app an additional
michael@0 515 ; five seconds to close.
michael@0 516 ${If} "$TmpVal" == "FoundMessageWindow"
michael@0 517 Sleep 5000
michael@0 518 ${EndIf}
michael@0 519
michael@0 520 ${PushFilesToCheck}
michael@0 521
michael@0 522 ${un.CheckForFilesInUse} $TmpVal
michael@0 523
michael@0 524 Banner::destroy
michael@0 525
michael@0 526 ; If there are files in use $TmpVal will be "true"
michael@0 527 ${If} "$TmpVal" == "true"
michael@0 528 ; If the message window is found the call to ManualCloseAppPrompt will
michael@0 529 ; abort leaving the value of $TmpVal set to "FoundMessageWindow".
michael@0 530 StrCpy $TmpVal "FoundMessageWindow"
michael@0 531 ${un.ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_UNINSTALL)"
michael@0 532 ; If the message window is not found set $TmpVal to "true" so the restart
michael@0 533 ; required message is displayed.
michael@0 534 StrCpy $TmpVal "true"
michael@0 535 ${EndIf}
michael@0 536 ${EndIf}
michael@0 537 FunctionEnd
michael@0 538
michael@0 539 Function un.preConfirm
michael@0 540 ${If} ${FileExists} "$INSTDIR\distribution\modern-header.bmp"
michael@0 541 ${AndIf} $hHeaderBitmap == ""
michael@0 542 Delete "$PLUGINSDIR\modern-header.bmp"
michael@0 543 CopyFiles /SILENT "$INSTDIR\distribution\modern-header.bmp" "$PLUGINSDIR\modern-header.bmp"
michael@0 544 ${un.ChangeMUIHeaderImage} "$PLUGINSDIR\modern-header.bmp"
michael@0 545 ${EndIf}
michael@0 546
michael@0 547 ; Setup the unconfirm.ini file for the Custom Uninstall Confirm Page
michael@0 548 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Settings" NumFields "3"
michael@0 549
michael@0 550 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Type "label"
michael@0 551 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Text "$(UN_CONFIRM_UNINSTALLED_FROM)"
michael@0 552 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Left "0"
michael@0 553 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Right "-1"
michael@0 554 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Top "5"
michael@0 555 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 1" Bottom "15"
michael@0 556
michael@0 557 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Type "text"
michael@0 558 ; The contents of this control must be set as follows in the pre function
michael@0 559 ; ${MUI_INSTALLOPTIONS_READ} $1 "unconfirm.ini" "Field 2" "HWND"
michael@0 560 ; SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
michael@0 561 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" State ""
michael@0 562 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Left "0"
michael@0 563 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Right "-1"
michael@0 564 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Top "17"
michael@0 565 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" Bottom "30"
michael@0 566 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 2" flags "READONLY"
michael@0 567
michael@0 568 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Type "label"
michael@0 569 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Text "$(UN_CONFIRM_CLICK)"
michael@0 570 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Left "0"
michael@0 571 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Right "-1"
michael@0 572 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Top "130"
michael@0 573 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 3" Bottom "150"
michael@0 574
michael@0 575 ${If} "$TmpVal" == "true"
michael@0 576 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Type "label"
michael@0 577 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Text "$(SUMMARY_REBOOT_REQUIRED_UNINSTALL)"
michael@0 578 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Left "0"
michael@0 579 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Right "-1"
michael@0 580 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Top "35"
michael@0 581 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Field 4" Bottom "45"
michael@0 582
michael@0 583 WriteINIStr "$PLUGINSDIR\unconfirm.ini" "Settings" NumFields "4"
michael@0 584 ${EndIf}
michael@0 585
michael@0 586 !insertmacro MUI_HEADER_TEXT "$(UN_CONFIRM_PAGE_TITLE)" "$(UN_CONFIRM_PAGE_SUBTITLE)"
michael@0 587 ; The Summary custom page has a textbox that will automatically receive
michael@0 588 ; focus. This sets the focus to the Install button instead.
michael@0 589 !insertmacro MUI_INSTALLOPTIONS_INITDIALOG "unconfirm.ini"
michael@0 590 GetDlgItem $0 $HWNDPARENT 1
michael@0 591 System::Call "user32::SetFocus(i r0, i 0x0007, i,i)i"
michael@0 592 ${MUI_INSTALLOPTIONS_READ} $1 "unconfirm.ini" "Field 2" "HWND"
michael@0 593 SendMessage $1 ${WM_SETTEXT} 0 "STR:$INSTDIR"
michael@0 594 !insertmacro MUI_INSTALLOPTIONS_SHOW
michael@0 595 FunctionEnd
michael@0 596
michael@0 597 Function un.leaveConfirm
michael@0 598 ; Try to delete the app executable and if we can't delete it try to find the
michael@0 599 ; app's message window and prompt the user to close the app. This allows
michael@0 600 ; running an instance that is located in another directory. If for whatever
michael@0 601 ; reason there is no message window we will just rename the app's files and
michael@0 602 ; then remove them on restart if they are in use.
michael@0 603 ClearErrors
michael@0 604 ${DeleteFile} "$INSTDIR\${FileMainEXE}"
michael@0 605 ${If} ${Errors}
michael@0 606 ${un.ManualCloseAppPrompt} "${WindowClass}" "$(WARN_MANUALLY_CLOSE_APP_UNINSTALL)"
michael@0 607 ${EndIf}
michael@0 608 FunctionEnd
michael@0 609
michael@0 610 !ifndef NO_UNINSTALL_SURVEY
michael@0 611 Function un.preFinish
michael@0 612 ; Do not modify the finish page if there is a reboot pending
michael@0 613 ${Unless} ${RebootFlag}
michael@0 614 ; Setup the survey controls, functions, etc.
michael@0 615 StrCpy $TmpVal "SOFTWARE\Microsoft\IE Setup\Setup"
michael@0 616 ClearErrors
michael@0 617 ReadRegStr $0 HKLM $TmpVal "Path"
michael@0 618 ${If} ${Errors}
michael@0 619 !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "NumFields" "3"
michael@0 620 ${Else}
michael@0 621 ExpandEnvStrings $0 "$0" ; this value will usually contain %programfiles%
michael@0 622 ${If} $0 != "\"
michael@0 623 StrCpy $0 "$0\"
michael@0 624 ${EndIf}
michael@0 625 StrCpy $0 "$0\iexplore.exe"
michael@0 626 ClearErrors
michael@0 627 GetFullPathName $TmpVal $0
michael@0 628 ${If} ${Errors}
michael@0 629 !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "NumFields" "3"
michael@0 630 ${Else}
michael@0 631 ; When we add an optional action to the finish page the cancel button
michael@0 632 ; is enabled. This disables it and leaves the finish button as the
michael@0 633 ; only choice.
michael@0 634 !insertmacro MUI_INSTALLOPTIONS_WRITE "ioSpecial.ini" "settings" "cancelenabled" "0"
michael@0 635 ${EndIf}
michael@0 636 ${EndIf}
michael@0 637 ${EndUnless}
michael@0 638 FunctionEnd
michael@0 639 !endif
michael@0 640
michael@0 641 ################################################################################
michael@0 642 # Initialization Functions
michael@0 643
michael@0 644 Function .onInit
michael@0 645 ; Remove the current exe directory from the search order.
michael@0 646 ; This only effects LoadLibrary calls and not implicitly loaded DLLs.
michael@0 647 System::Call 'kernel32::SetDllDirectoryW(w "")'
michael@0 648
michael@0 649 ; We need this set up for most of the helper.exe operations.
michael@0 650 ${UninstallOnInitCommon}
michael@0 651 FunctionEnd
michael@0 652
michael@0 653 Function un.onInit
michael@0 654 ; Remove the current exe directory from the search order.
michael@0 655 ; This only effects LoadLibrary calls and not implicitly loaded DLLs.
michael@0 656 System::Call 'kernel32::SetDllDirectoryW(w "")'
michael@0 657
michael@0 658 StrCpy $LANGUAGE 0
michael@0 659
michael@0 660 ${un.UninstallUnOnInitCommon}
michael@0 661
michael@0 662 ; The commands inside this ifndef are needed prior to NSIS 3.0a2 and can be
michael@0 663 ; removed after we require NSIS 3.0a2 or greater.
michael@0 664 !ifndef NSIS_PACKEDVERSION
michael@0 665 ${If} ${AtLeastWinVista}
michael@0 666 System::Call 'user32::SetProcessDPIAware()'
michael@0 667 ${EndIf}
michael@0 668 !endif
michael@0 669
michael@0 670 !insertmacro InitInstallOptionsFile "unconfirm.ini"
michael@0 671 FunctionEnd
michael@0 672
michael@0 673 Function .onGUIEnd
michael@0 674 ${OnEndCommon}
michael@0 675 FunctionEnd
michael@0 676
michael@0 677 Function un.onGUIEnd
michael@0 678 ${un.OnEndCommon}
michael@0 679 FunctionEnd

mercurial