Bug 404541 - [MSFT-7816] on Vista / Windows 7 installer does not elevate or ask to be elevated. r=jmathies

This commit is contained in:
Robert Strong 2009-05-20 15:49:24 -07:00
parent 7e36be9390
commit cd3e1c9a96
4 changed files with 384 additions and 177 deletions

View File

@ -60,6 +60,14 @@ Var AddQuickLaunchSC
Var AddDesktopSC
Var PageName
; On Vista and above attempt to elevate Standard Users in addition to users that
; are a member of the Administrators group.
!define NONADMIN_ELEVATE
; Don't use the PreDirectoryCommon macro's code for finding a pre-existing
; installation directory.
!define NO_INSTDIR_PREDIRCOMMON
!define AbortSurveyURL "http://www.kampyle.com/feedback_form/ff-feedback-form.php?site_code=8166124&form_id=12116&url="
; Other included files may depend upon these includes!
@ -95,6 +103,7 @@ VIAddVersionKey "OriginalFilename" "setup.exe"
!insertmacro _LoggingShortcutsCommon
!insertmacro AddDDEHandlerValues
!insertmacro CanWriteToInstallDir
!insertmacro ChangeMUIHeaderImage
!insertmacro CheckForFilesInUse
!insertmacro CleanUpdatesDir
@ -348,6 +357,10 @@ Section "-Application" APP_IDX
${FixClassKeys}
; Uninstall keys can only exist under HKLM on some versions of windows. Since
; it doesn't cause problems always add them.
${SetUninstallKeys}
; On install always add the FirefoxHTML and FirefoxURL keys.
; An empty string is used for the 5th param because FirefoxHTML and FirefoxURL
; are not protocol handlers.
@ -361,16 +374,13 @@ Section "-Application" APP_IDX
${AddDDEHandlerValues} "FirefoxURL" "$2" "$8,1" "${AppRegName} URL" "true" \
"${DDEApplication}" "$3" "WWW_OpenURL"
${FixShellIconHandler}
; The following keys should only be set if we can write to HKLM
${If} $TmpVal == "HKLM"
; Uninstall keys can only exist under HKLM on some versions of windows.
${SetUninstallKeys}
; Set the Start Menu Internet and Vista Registered App HKLM registry keys.
${SetStartMenuInternet}
${FixShellIconHandler}
; If we are writing to HKLM and create the quick launch and the desktop
; shortcuts set IconsVisible to 1 otherwise to 0.
${StrFilter} "${FileMainEXE}" "+" "" "" $R9
@ -392,11 +402,11 @@ Section "-Application" APP_IDX
StrCpy $0 "Software\Microsoft\MediaPlayer\ShimInclusionList\$R9"
${CreateRegKey} "$TmpVal" "$0" 0
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
; Create shortcuts
${LogHeader} "Adding Shortcuts"
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
; Always add the relative path to the application's Start Menu directory and
; the application's shortcuts to the shortcuts log ini file. The
; DeleteShortcuts macro will do the right thing on uninstall if they don't
@ -407,6 +417,10 @@ Section "-Application" APP_IDX
${LogQuickLaunchShortcut} "${BrandFullName}.lnk"
${LogDesktopShortcut} "${BrandFullName}.lnk"
; UAC only allows elevating to an Admin account so there is no need to add
; the Start Menu or Desktop shortcuts from the original unelevated process
; since this will either add it for the user if unelevated or All Users if
; elevated.
${If} $AddStartMenuSC == 1
${Unless} ${FileExists} "$SMPROGRAMS\$StartMenuDir"
CreateDirectory "$SMPROGRAMS\$StartMenuDir"
@ -418,17 +432,31 @@ Section "-Application" APP_IDX
${LogMsg} "Added Shortcut: $SMPROGRAMS\$StartMenuDir\${BrandFullName} ($(SAFE_MODE)).lnk"
${EndIf}
${If} $AddQuickLaunchSC == 1
CreateShortCut "$QUICKLAUNCH\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
${LogMsg} "Added Shortcut: $QUICKLAUNCH\${BrandFullName}.lnk"
${EndIf}
!insertmacro MUI_STARTMENU_WRITE_END
${If} $AddDesktopSC == 1
CreateShortCut "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
${LogMsg} "Added Shortcut: $DESKTOP\${BrandFullName}.lnk"
${EndIf}
!insertmacro MUI_STARTMENU_WRITE_END
; If elevated the Quick Launch shortcut must be added from the unelevated
; original process.
${If} $AddQuickLaunchSC == 1
ClearErrors
${GetParameters} $0
${GetOptions} "$0" "/UAC:" $0
${If} ${Errors}
Call AddQuickLaunchShortcut
${LogMsg} "Added Shortcut: $QUICKLAUNCH\${BrandFullName}.lnk"
${Else}
; It is not possible to add a log entry from the unelevated process so
; add the log entry without the path since there is no simple way to know
; the correct full path.
${LogMsg} "Added Quick Launch Shortcut: ${BrandFullName}.lnk"
GetFunctionAddress $0 AddQuickLaunchShortcut
UAC::ExecCodeSegment $0
${EndIf}
${EndIf}
SectionEnd
; Cleanup operations to perform at the end of the installation.
@ -441,7 +469,15 @@ Section "-InstallEndCleanup"
${MUI_INSTALLOPTIONS_READ} $0 "options.ini" "Field 6" "State"
${If} "$0" == "1"
${LogHeader} "Setting as the default browser"
${SetAsDefaultAppUser}
ClearErrors
${GetParameters} $0
${GetOptions} "$0" "/UAC:" $0
${If} ${Errors}
Call SetAsDefaultAppUserHKCU
${Else}
GetFunctionAddress $0 SetAsDefaultAppUserHKCU
UAC::ExecCodeSegment $0
${EndIf}
${EndIf}
${EndUnless}
@ -452,9 +488,9 @@ Section "-InstallEndCleanup"
${InstallEndCleanupCommon}
; If we have to reboot give SHChangeNotify time to finish the refreshing
; the icons so the OS doesn't display the icons from helper.exe
${If} ${RebootFlag}
; When a reboot is required give SHChangeNotify time to finish the
; refreshing the icons so the OS doesn't display the icons from helper.exe
Sleep 10000
${LogHeader} "Reboot Required To Finish Installation"
; ${FileMainEXE}.moz-upgrade should never exist but just in case...
@ -558,6 +594,10 @@ FunctionEnd
################################################################################
# Helper Functions
Function AddQuickLaunchShortcut
CreateShortCut "$QUICKLAUNCH\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
FunctionEnd
Function CheckExistingInstall
; If there is a pending file copy from a previous uninstall don't allow
; installing until after the system has rebooted.
@ -673,22 +713,37 @@ Function leaveOptions
StrCmp $R0 "1" +1 +2
StrCpy $InstallType ${INSTALLTYPE_CUSTOM}
${If} $InstallType != ${INSTALLTYPE_CUSTOM}
!ifndef NO_INSTDIR_FROM_REG
SetShellVarContext all ; Set SHCTX to HKLM
${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
SetShellVarContext all ; Set SHCTX to HKLM
${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
StrCmp "$R9" "false" +1 fix_install_dir
StrCmp "$R9" "false" +1 fix_install_dir
SetShellVarContext current ; Set SHCTX to HKCU
${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
SetShellVarContext current ; Set SHCTX to HKCU
${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
fix_install_dir:
StrCmp "$R9" "false" +2 +1
StrCpy $INSTDIR "$R9"
fix_install_dir:
StrCmp "$R9" "false" +2 +1
StrCpy $INSTDIR "$R9"
!endif
Call CheckExistingInstall
; If the user doesn't have write access to the installation directory set
; the installation directory to a subdirectory of the All Users application
; directory and if the user can't write to that location set the installation
; directory to a subdirectory of the users local application directory
; (e.g. non-roaming).
${CanWriteToInstallDir} $R8
${If} "$R8" == "false"
SetShellVarContext all ; Set SHCTX to All Users
StrCpy $INSTDIR "$APPDATA\${BrandFullName}\"
${If} ${FileExists} "$INSTDIR"
; Always display the long path if the path already exists.
${GetLongPath} "$INSTDIR" $INSTDIR
${EndIf}
${CanWriteToInstallDir} $R8
${If} "$R8" == "false"
StrCpy $INSTDIR "$LOCALAPPDATA\${BrandFullName}\"
${EndIf}
${EndIf}
FunctionEnd
@ -699,6 +754,9 @@ FunctionEnd
Function leaveDirectory
${LeaveDirectoryCommon} "$(WARN_DISK_SPACE)" "$(WARN_WRITE_ACCESS)"
${If} $InstallType != ${INSTALLTYPE_CUSTOM}
Call CheckExistingInstall
${EndIf}
FunctionEnd
Function preShortcuts
@ -867,8 +925,29 @@ Function .onInit
!insertmacro InitInstallOptionsFile "shortcuts.ini"
!insertmacro InitInstallOptionsFile "summary.ini"
; Setup the options.ini file for the Custom Options Page
WriteINIStr "$PLUGINSDIR\options.ini" "Settings" NumFields "6"
ClearErrors
${If} ${AtLeastWinVista}
WriteRegStr HKLM "Software\Mozilla" "${BrandShortName}InstallerTest" "Write Test"
${EndIf}
${If} ${Errors}
; Setup the options.ini file for the Custom Options Page without the option
; to set as default for Vista and above since the installer is unable to
; write to HKLM.
WriteINIStr "$PLUGINSDIR\options.ini" "Settings" NumFields "5"
${Else}
DeleteRegValue HKLM "Software\Mozilla" "${BrandShortName}InstallerTest"
; Setup the options.ini file for the Custom Options Page with the option
; to set as default
WriteINIStr "$PLUGINSDIR\options.ini" "Settings" NumFields "6"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Type "checkbox"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Text "$(OPTIONS_MAKE_DEFAULT)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Left "0"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Right "-1"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Top "124"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Bottom "145"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" State "1"
${EndIf}
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Type "label"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 1" Text "$(OPTIONS_SUMMARY)"
@ -908,14 +987,6 @@ Function .onInit
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Top "67"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 5" Bottom "87"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Type "checkbox"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Text "$(OPTIONS_MAKE_DEFAULT)"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Left "0"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Right "-1"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Top "124"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" Bottom "145"
WriteINIStr "$PLUGINSDIR\options.ini" "Field 6" State "1"
; Setup the shortcuts.ini file for the Custom Shortcuts Page
WriteINIStr "$PLUGINSDIR\shortcuts.ini" "Settings" NumFields "4"

View File

@ -71,8 +71,6 @@
${SetStartMenuInternet}
${EndIf}
${SetUninstallKeys}
ReadRegStr $0 HKLM "Software\mozilla.org\Mozilla" "CurrentVersion"
${If} "$0" != "${GREVersion}"
WriteRegStr HKLM "Software\mozilla.org\Mozilla" "CurrentVersion" "${GREVersion}"
@ -81,9 +79,9 @@
${RemoveDeprecatedKeys}
; Add Software\Mozilla\ registry entries
${SetAppKeys}
${FixClassKeys}
${SetUninstallKeys}
; Remove files that may be left behind by the application in the
; VirtualStore directory.
@ -96,51 +94,6 @@
!macroend
!define PostUpdate "!insertmacro PostUpdate"
!macro SetAsDefaultAppUser
; It is only possible to set this installation of the application as the
; StartMenuInternet handler if it was added to the HKLM StartMenuInternet
; registry keys.
; http://support.microsoft.com/kb/297878
${StrFilter} "${FileMainEXE}" "+" "" "" $R9
ClearErrors
ReadRegStr $0 HKLM "Software\Clients\StartMenuInternet\$R9\DefaultIcon" ""
IfErrors updateclientkeys +1
${GetPathFromString} "$0" $0
${GetParent} "$0" $0
IfFileExists "$0" +1 updateclientkeys
${GetLongPath} "$0" $0
StrCmp "$0" "$INSTDIR" setdefaultuser +1
updateclientkeys:
; Calls after ElevateUAC won't be made if the user can elevate. They
; will be made in the new elevated process if the user allows elevation.
${ElevateUAC}
${SetStartMenuInternet}
setdefaultuser:
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
${FixShellIconHandler}
WriteRegStr HKCU "Software\Clients\StartMenuInternet" "" "$R9"
${If} ${AtLeastWinVista}
ClearErrors
ReadRegStr $0 HKLM "Software\RegisteredApplications" "${AppRegName}"
; Only register as the handler on Vista if the app registry name exists
; under the RegisteredApplications registry key.
${Unless} ${Errors}
AppAssocReg::SetAppAsDefaultAll "${AppRegName}"
${EndUnless}
${EndIf}
${RemoveDeprecatedKeys}
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
${SetHandlers}
!macroend
!define SetAsDefaultAppUser "!insertmacro SetAsDefaultAppUser"
!macro SetAsDefaultAppGlobal
${RemoveDeprecatedKeys}
@ -154,11 +107,9 @@
!macroend
!define SetAsDefaultAppGlobal "!insertmacro SetAsDefaultAppGlobal"
!macro FixReg
${SetAsDefaultAppUser}
!macroend
!define FixReg "!insertmacro FixReg"
; Removes shortcuts for this installation. This should also remove the
; application from Open With for the file types the application handles
; (bug 370480).
!macro HideShortcuts
${StrFilter} "${FileMainEXE}" "+" "" "" $0
StrCpy $R1 "Software\Clients\StartMenuInternet\$0\InstallInfo"
@ -196,6 +147,8 @@
!macroend
!define HideShortcuts "!insertmacro HideShortcuts"
; Adds shortcuts for this installation. This should also add the application
; to Open With for the file types the application handles (bug 370480).
!macro ShowShortcuts
${StrFilter} "${FileMainEXE}" "+" "" "" $0
StrCpy $R1 "Software\Clients\StartMenuInternet\$0\InstallInfo"
@ -219,6 +172,8 @@
!macroend
!define ShowShortcuts "!insertmacro ShowShortcuts"
; Adds the protocol and file handler registry entries for making Firefox the
; default handler (uses SHCTX).
!macro SetHandlers
${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
@ -226,27 +181,27 @@
StrCpy $2 "$\"$8$\" -requestPending -osint -url $\"%1$\""
; Associate the file handlers with FirefoxHTML
ReadRegStr $6 HKCR ".htm" ""
ReadRegStr $6 SHCTX "$0\.htm" ""
${If} "$6" != "FirefoxHTML"
WriteRegStr SHCTX "$0\.htm" "" "FirefoxHTML"
${EndIf}
ReadRegStr $6 HKCR ".html" ""
ReadRegStr $6 SHCTX "$0\.html" ""
${If} "$6" != "FirefoxHTML"
WriteRegStr SHCTX "$0\.html" "" "FirefoxHTML"
${EndIf}
ReadRegStr $6 HKCR ".shtml" ""
ReadRegStr $6 SHCTX "$0\.shtml" ""
${If} "$6" != "FirefoxHTML"
WriteRegStr SHCTX "$0\.shtml" "" "FirefoxHTML"
${EndIf}
ReadRegStr $6 HKCR ".xht" ""
ReadRegStr $6 SHCTX "$0\.xht" ""
${If} "$6" != "FirefoxHTML"
WriteRegStr SHCTX "$0\.xht" "" "FirefoxHTML"
${EndIf}
ReadRegStr $6 HKCR ".xhtml" ""
ReadRegStr $6 SHCTX "$0\.xhtml" ""
${If} "$6" != "FirefoxHTML"
WriteRegStr SHCTX "$0\.xhtml" "" "FirefoxHTML"
${EndIf}
@ -273,6 +228,9 @@
!macroend
!define SetHandlers "!insertmacro SetHandlers"
; Adds the HKLM\Software\Clients\StartMenuInternet\FIREFOX.EXE registry
; entries (does not use SHCTX).
;
; The values for StartMenuInternet are only valid under HKLM and there can only
; be one installation registerred under StartMenuInternet per application since
; the key name is derived from the main application executable.
@ -301,7 +259,7 @@
ClearErrors
ReadRegDWORD $1 HKLM "$0\InstallInfo" "IconsVisible"
; If the IconsVisible name vale pair doesn't exist add it otherwise the
; If the IconsVisible name value pair doesn't exist add it otherwise the
; application won't be displayed in Set Program Access and Defaults.
${If} ${Errors}
${If} ${FileExists} "$QUICKLAUNCH\${BrandFullName}.lnk"
@ -341,26 +299,24 @@
!macroend
!define SetStartMenuInternet "!insertmacro SetStartMenuInternet"
; The IconHandler reference for FirefoxHTML can end up in an inconsistent state
; due to changes not being detected by the IconHandler for side by side
; installs (see bug 268512). The symptoms can be either an incorrect icon or no
; icon being displayed for files associated with Firefox (does not use SHCTX).
!macro FixShellIconHandler
; The IconHandler reference for FirefoxHTML can end up in an inconsistent
; state due to changes not being detected by the IconHandler for side by side
; installs. The symptoms can be either an incorrect icon or no icon being
; displayed for files associated with Firefox. By setting it here it will
; always reference the install referenced in the
; HKLM\Software\Classes\FirefoxHTML registry key.
${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
ClearErrors
ReadRegStr $2 HKLM "Software\Classes\FirefoxHTML\ShellEx\IconHandler" ""
ReadRegStr $1 HKLM "Software\Classes\FirefoxHTML\ShellEx\IconHandler" ""
${Unless} ${Errors}
ClearErrors
ReadRegStr $3 HKLM "Software\Classes\CLSID\$2\Old Icon\FirefoxHTML\DefaultIcon" ""
${Unless} ${Errors}
WriteRegStr HKLM "Software\Classes\CLSID\$2\Old Icon\FirefoxHTML\DefaultIcon" "" "$8,1"
${EndUnless}
ReadRegStr $1 HKLM "Software\Classes\FirefoxHTML\" ""
${GetLongPath} "$INSTDIR\${FileMainEXE}" $2
${If} "$1" != "$2,1"
WriteRegStr HKLM "Software\Classes\FirefoxHTML\DefaultIcon" "" "$2,1"
${EndIf}
${EndUnless}
!macroend
!define FixShellIconHandler "!insertmacro FixShellIconHandler"
; Add Software\Mozilla\ registry entries (uses SHCTX).
!macro SetAppKeys
${GetLongPath} "$INSTDIR" $8
StrCpy $0 "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Main"
@ -389,25 +345,46 @@
!macroend
!define SetAppKeys "!insertmacro SetAppKeys"
; Add uninstall registry entries. This macro tests for write access to determine
; if the uninstall keys should be added to HKLM or HKCU.
!macro SetUninstallKeys
StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\Uninstall\${BrandFullNameInternal} (${AppVersion})"
WriteRegStr HKLM "$0" "${BrandShortName}InstallerTest" "Write Test"
${If} ${Errors}
StrCpy $1 "HKCU"
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
${Else}
StrCpy $1 "HKLM"
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
DeleteRegValue HKLM "$0" "${BrandShortName}InstallerTest"
${EndIf}
${GetLongPath} "$INSTDIR" $8
; Write the uninstall registry keys
${WriteRegStr2} $TmpVal "$0" "Comments" "${BrandFullNameInternal}" 0
${WriteRegStr2} $TmpVal "$0" "DisplayIcon" "$8\${FileMainEXE},0" 0
${WriteRegStr2} $TmpVal "$0" "DisplayName" "${BrandFullNameInternal} (${AppVersion})" 0
${WriteRegStr2} $TmpVal "$0" "DisplayVersion" "${AppVersion} (${AB_CD})" 0
${WriteRegStr2} $TmpVal "$0" "InstallLocation" "$8" 0
${WriteRegStr2} $TmpVal "$0" "Publisher" "Mozilla" 0
${WriteRegStr2} $TmpVal "$0" "UninstallString" "$8\uninstall\helper.exe" 0
${WriteRegStr2} $TmpVal "$0" "URLInfoAbout" "${URLInfoAbout}" 0
${WriteRegStr2} $TmpVal "$0" "URLUpdateInfo" "${URLUpdateInfo}" 0
${WriteRegDWORD2} $TmpVal "$0" "NoModify" 1 0
${WriteRegDWORD2} $TmpVal "$0" "NoRepair" 1 0
${WriteRegStr2} $1 "$0" "Comments" "${BrandFullNameInternal}" 0
${WriteRegStr2} $1 "$0" "DisplayIcon" "$8\${FileMainEXE},0" 0
${WriteRegStr2} $1 "$0" "DisplayName" "${BrandFullNameInternal} (${AppVersion})" 0
${WriteRegStr2} $1 "$0" "DisplayVersion" "${AppVersion} (${AB_CD})" 0
${WriteRegStr2} $1 "$0" "InstallLocation" "$8" 0
${WriteRegStr2} $1 "$0" "Publisher" "Mozilla" 0
${WriteRegStr2} $1 "$0" "UninstallString" "$8\uninstall\helper.exe" 0
${WriteRegStr2} $1 "$0" "URLInfoAbout" "${URLInfoAbout}" 0
${WriteRegStr2} $1 "$0" "URLUpdateInfo" "${URLUpdateInfo}" 0
${WriteRegDWORD2} $1 "$0" "NoModify" 1 0
${WriteRegDWORD2} $1 "$0" "NoRepair" 1 0
${If} "$TmpVal" == "HKLM"
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
${Else}
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
${EndIf}
!macroend
!define SetUninstallKeys "!insertmacro SetUninstallKeys"
; Add app specific handler registry entries under Software\Classes if they
; don't exist (does not use SHCTX).
!macro FixClassKeys
StrCpy $1 "SOFTWARE\Classes"
@ -436,7 +413,7 @@
!define FixClassKeys "!insertmacro FixClassKeys"
; Updates protocol handlers if their registry open command value is for this
; install location
; install location (uses SHCTX).
!macro UpdateProtocolHandlers
; Store the command to open the app with an url in a register for easy access.
${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
@ -480,6 +457,7 @@
!macroend
!define UpdateProtocolHandlers "!insertmacro UpdateProtocolHandlers"
; Removes various registry entries for reasons noted below (does not use SHCTX).
!macro RemoveDeprecatedKeys
StrCpy $0 "SOFTWARE\Classes"
; Remove support for launching gopher urls from the shell during install or
@ -568,3 +546,104 @@
Push "${FileMainEXE}"
!macroend
!define PushFilesToCheck "!insertmacro PushFilesToCheck"
; Sets this installation as the default browser by setting the registry keys
; under HKEY_CURRENT_USER via registry calls and using the AppAssocReg NSIS
; plugin for Vista and above. This is a function instead of a macro so it is
; easily called from an elevated instance of the binary. Since this can be
; called by an elevated instance logging is not performed in this function.
Function SetAsDefaultAppUserHKCU
; Only set as the user's StartMenuInternet browser if the StartMenuInternet
; registry keys are for this install.
${StrFilter} "${FileMainEXE}" "+" "" "" $R9
ClearErrors
ReadRegStr $0 HKLM "Software\Clients\StartMenuInternet\$R9\DefaultIcon" ""
${Unless} ${Errors}
${GetPathFromString} "$0" $0
${GetParent} "$0" $0
${If} ${FileExists} "$0"
${GetLongPath} "$0" $0
${If} "$0" == "$INSTDIR"
WriteRegStr HKCU "Software\Clients\StartMenuInternet" "" "$R9"
${EndIf}
${EndIf}
${EndUnless}
SetShellVarContext current ; Set SHCTX to the current user (e.g. HKCU)
${SetHandlers}
${If} ${AtLeastWinVista}
; Only register as the handler on Vista and above if the app registry name
; exists under the RegisteredApplications registry key. The protocol and
; file handlers set previously at the user level will associate this install
; as the default browser.
ClearErrors
ReadRegStr $0 HKLM "Software\RegisteredApplications" "${AppRegName}"
${Unless} ${Errors}
AppAssocReg::SetAppAsDefaultAll "${AppRegName}"
${EndUnless}
${EndIf}
${RemoveDeprecatedKeys}
FunctionEnd
; The !ifdef NO_LOG prevents warnings when compiling the installer.nsi due to
; this function only being used by the uninstaller.nsi.
!ifdef NO_LOG
Function SetAsDefaultAppUser
; It is only possible to set this installation of the application as the
; StartMenuInternet handler if it was added to the HKLM StartMenuInternet
; registry keys.
; http://support.microsoft.com/kb/297878
; Check if this install location registered as the StartMenuInternet client
${StrFilter} "${FileMainEXE}" "+" "" "" $R9
ClearErrors
ReadRegStr $0 HKLM "Software\Clients\StartMenuInternet\$R9\DefaultIcon" ""
${Unless} ${Errors}
${GetPathFromString} "$0" $0
${GetParent} "$0" $0
${If} ${FileExists} "$0"
${GetLongPath} "$0" $0
${If} "$0" == "$INSTDIR"
; Check if this is running in an elevated process
ClearErrors
${GetParameters} $0
${GetOptions} "$0" "/UAC:" $0
${If} ${Errors} ; Not elevated
Call SetAsDefaultAppUserHKCU
${Else} ; Elevated - execute the function in the unelevated process
GetFunctionAddress $0 SetAsDefaultAppUserHKCU
UAC::ExecCodeSegment $0
${EndIf}
Return ; Nothing more needs to be done
${EndIf}
${EndIf}
${EndUnless}
; The code after ElevateUAC won't be executed on Vista and above when the
; user:
; a) is a member of the administrators group (e.g. elevation is required)
; b) is not a member of the administrators group and chooses to elevate
${ElevateUAC}
${SetStartMenuInternet}
SetShellVarContext all ; Set SHCTX to all users (e.g. HKLM)
${FixShellIconHandler}
${RemoveDeprecatedKeys}
ClearErrors
${GetParameters} $0
${GetOptions} "$0" "/UAC:" $0
${If} ${Errors}
Call SetAsDefaultAppUserHKCU
${Else}
GetFunctionAddress $0 SetAsDefaultAppUserHKCU
UAC::ExecCodeSegment $0
${EndIf}
FunctionEnd
!define SetAsDefaultAppUser "Call SetAsDefaultAppUser"
!endif

View File

@ -52,6 +52,10 @@ RequestExecutionLevel user
!addplugindir ./
; On Vista and above attempt to elevate Standard Users in addition to users that
; are a member of the Administrators group.
!define NONADMIN_ELEVATE
; prevents compiling of the reg write logging.
!define NO_LOG
@ -88,6 +92,7 @@ VIAddVersionKey "OriginalFilename" "helper.exe"
!insertmacro AddDDEHandlerValues
!insertmacro CleanVirtualStore
!insertmacro ElevateUAC
!insertmacro FindSMProgramsDir
!insertmacro GetLongPath
!insertmacro GetPathFromString

View File

@ -4451,26 +4451,24 @@
Push $R6
Push $R5
!ifdef ___WINVER__NSH___
${Unless} ${AtLeastWin2000}
; XXX-rstrong - some systems fail the AtLeastWin2000 test for an
; unknown reason. To work around this also check if the Windows NT
; registry Key exists and if it does if the first char in
; CurrentVersion is equal to 3 (Windows NT 3.5 and 3.5.1) or 4
; (Windows NT 4).
StrCpy $R8 ""
ClearErrors
ReadRegStr $R8 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
StrCpy $R8 "$R8" 1
${If} ${Errors}
${OrIf} "$R8" == "3"
${OrIf} "$R8" == "4"
MessageBox MB_OK|MB_ICONSTOP "$R9" IDOK
; Nothing initialized so no need to call OnEndCommon
Quit
${EndIf}
${EndUnless}
!endif
${Unless} ${AtLeastWin2000}
; XXX-rstrong - some systems fail the AtLeastWin2000 test for an
; unknown reason. To work around this also check if the Windows NT
; registry Key exists and if it does if the first char in
; CurrentVersion is equal to 3 (Windows NT 3.5 and 3.5.1) or 4
; (Windows NT 4).
StrCpy $R8 ""
ClearErrors
ReadRegStr $R8 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion"
StrCpy $R8 "$R8" 1
${If} ${Errors}
${OrIf} "$R8" == "3"
${OrIf} "$R8" == "4"
MessageBox MB_OK|MB_ICONSTOP "$R9" IDOK
; Nothing initialized so no need to call OnEndCommon
Quit
${EndIf}
${EndUnless}
${GetParameters} $R8
@ -4673,7 +4671,9 @@
ClearErrors
${GetOptions} "$R0" "/HideShortcuts" $R2
IfErrors showshortcuts +1
!ifndef NONADMIN_ELEVATE
${ElevateUAC}
!endif
${HideShortcuts}
GoTo finish
@ -4682,7 +4682,9 @@
ClearErrors
${GetOptions} "$R0" "/ShowShortcuts" $R2
IfErrors defaultappuser +1
!ifndef NONADMIN_ELEVATE
${ElevateUAC}
!endif
${ShowShortcuts}
GoTo finish
@ -4801,6 +4803,7 @@
Function PreDirectoryCommon
Push $R9
!ifndef NO_INSTDIR_PREDIRCOMMON
!ifndef NO_INSTDIR_FROM_REG
SetShellVarContext all ; Set SHCTX to HKLM
${GetSingleInstallPath} "Software\Mozilla\${BrandFullNameInternal}" $R9
@ -4813,6 +4816,7 @@
fix_install_dir:
StrCmp "$R9" "false" +2 +1
StrCpy $INSTDIR "$R9"
!endif
!endif
IfFileExists "$INSTDIR" +1 check_install_dir
@ -4829,9 +4833,9 @@
check_install_dir:
IntCmp $InstallType ${INSTALLTYPE_CUSTOM} end +1 +1
${CanWriteToInstallDir} $R9
StrCmp $R9 "false" end +1
StrCmp "$R9" "false" end +1
${CheckDiskSpace} $R9
StrCmp $R9 "false" end +1
StrCmp "$R9" "false" end +1
Abort
end:
@ -5020,24 +5024,22 @@
!macro ElevateUAC
!ifndef ${_MOZFUNC_UN}ElevateUAC
!ifdef ___WINVER__NSH___
!define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
!insertmacro ${_MOZFUNC_UN_TMP}GetOptions
!insertmacro ${_MOZFUNC_UN_TMP}GetParameters
!undef _MOZFUNC_UN
!define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
!undef _MOZFUNC_UN_TMP
!endif
!define _MOZFUNC_UN_TMP ${_MOZFUNC_UN}
!insertmacro ${_MOZFUNC_UN_TMP}GetOptions
!insertmacro ${_MOZFUNC_UN_TMP}GetParameters
!undef _MOZFUNC_UN
!define _MOZFUNC_UN ${_MOZFUNC_UN_TMP}
!undef _MOZFUNC_UN_TMP
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!define ${_MOZFUNC_UN}ElevateUAC "!insertmacro ${_MOZFUNC_UN}ElevateUACCall"
Function ${_MOZFUNC_UN}ElevateUAC
!ifdef ___WINVER__NSH___
Push $R9
Push $0
Push $R9
Push $0
!ifndef NONADMIN_ELEVATE
${If} ${AtLeastWinVista}
UAC::IsAdmin
; If the user is not an admin already
@ -5068,10 +5070,64 @@
${EndIf}
${EndIf}
${EndIf}
!else
${If} ${AtLeastWinVista}
UAC::IsAdmin
; If the user is not an admin already
${If} "$0" != "1"
UAC::SupportsUAC
; If the system supports UAC require that the user elevate
${If} "$0" == "1"
UAC::GetElevationType
; If the user account has a split token
${If} "$0" == "3"
UAC::RunElevated
UAC::Unload
; Nothing besides UAC initialized so no need to call OnEndCommon
Quit
${EndIf}
${Else}
; Check if UAC is enabled. If the user has turned UAC on or off
; without rebooting this value will be incorrect. This is an
; edgecase that we have to live with when trying to allow
; installing when the user doesn't have privileges such as a public
; computer while trying to also achieve UAC elevation. When this
; happens the user will be presented with the runas dialog if the
; value is 1 and won't be presented with the UAC dialog when the
; value is 0.
ReadRegDWord $R9 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "EnableLUA"
${If} "$R9" == "1"
; This will display the UAC version of the runas dialog which
; requires a password for an existing user account.
UAC::RunElevated
${If} "$0" == "0" ; Was elevation successful
UAC::Unload
; Nothing besides UAC initialized so no need to call OnEndCommon
Quit
${EndIf}
; Unload UAC since the elevation request was not successful and
; install anyway.
UAC::Unload
${EndIf}
${EndIf}
${Else}
ClearErrors
${${_MOZFUNC_UN}GetParameters} $R9
${${_MOZFUNC_UN}GetOptions} "$R9" "/UAC:" $R9
; If the command line contains /UAC then we need to initialize the UAC
; plugin to use UAC::ExecCodeSegment to execute code in the
; non-elevated context.
${Unless} ${Errors}
UAC::RunElevated
${EndUnless}
${EndIf}
${EndIf}
!endif
Pop $0
Pop $R9
!endif
ClearErrors
Pop $0
Pop $R9
FunctionEnd
!verbose pop
@ -5116,38 +5172,34 @@
!macro UnloadUAC
!ifndef ${_MOZFUNC_UN}UnloadUAC
!ifdef ___WINVER__NSH___
!define _MOZFUNC_UN_TMP_UnloadUAC ${_MOZFUNC_UN}
!insertmacro ${_MOZFUNC_UN_TMP_UnloadUAC}GetOptions
!insertmacro ${_MOZFUNC_UN_TMP_UnloadUAC}GetParameters
!undef _MOZFUNC_UN
!define _MOZFUNC_UN ${_MOZFUNC_UN_TMP_UnloadUAC}
!undef _MOZFUNC_UN_TMP_UnloadUAC
!endif
!define _MOZFUNC_UN_TMP_UnloadUAC ${_MOZFUNC_UN}
!insertmacro ${_MOZFUNC_UN_TMP_UnloadUAC}GetOptions
!insertmacro ${_MOZFUNC_UN_TMP_UnloadUAC}GetParameters
!undef _MOZFUNC_UN
!define _MOZFUNC_UN ${_MOZFUNC_UN_TMP_UnloadUAC}
!undef _MOZFUNC_UN_TMP_UnloadUAC
!verbose push
!verbose ${_MOZFUNC_VERBOSE}
!define ${_MOZFUNC_UN}UnloadUAC "!insertmacro ${_MOZFUNC_UN}UnloadUACCall"
Function ${_MOZFUNC_UN}UnloadUAC
!ifdef ___WINVER__NSH___
${Unless} ${AtLeastWinVista}
Return
${EndUnless}
${Unless} ${AtLeastWinVista}
Return
${EndUnless}
Push $R9
Push $R9
ClearErrors
${${_MOZFUNC_UN}GetParameters} $R9
${${_MOZFUNC_UN}GetOptions} "$R9" "/UAC:" $R9
; If the command line contains /UAC then we need to unload the UAC plugin
IfErrors +2 +1
UAC::Unload
ClearErrors
${${_MOZFUNC_UN}GetParameters} $R9
${${_MOZFUNC_UN}GetOptions} "$R9" "/UAC:" $R9
; If the command line contains /UAC then we need to unload the UAC plugin
IfErrors +2 +1
UAC::Unload
ClearErrors
ClearErrors
Pop $R9
!endif
Pop $R9
FunctionEnd
!verbose pop