Bug 641784 - Stop the safe mode shortcut from being installed in the start menu. r=Standard8, ui-r=clarkbw
authorSiddharth Agarwal <sid.bugzilla@gmail.com>
Sat, 09 Apr 2011 01:34:42 +0530
changeset 7534 3dc32ae11f5b586cda97181954c21a6af7964de5
parent 7533 75db7044a4c77fa3b25ed7c67a04d698816ce9b1
child 7535 192dd0ddf4a50d2f610e5dfe886963697b939fa3
push id5774
push usersid.bugzilla@gmail.com
push dateFri, 08 Apr 2011 20:06:07 +0000
treeherdercomm-central@3dc32ae11f5b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8, clarkbw
bugs641784, 598779, 627848
Bug 641784 - Stop the safe mode shortcut from being installed in the start menu. r=Standard8, ui-r=clarkbw This is a port of Firefox bug 598779 and followup bug 627848.
mail/installer/windows/nsis/installer.nsi
mail/installer/windows/nsis/shared.nsh
mail/installer/windows/nsis/uninstaller.nsi
--- a/mail/installer/windows/nsis/installer.nsi
+++ b/mail/installer/windows/nsis/installer.nsi
@@ -49,23 +49,27 @@ SetDatablockOptimize on
 SetCompress off
 CRCCheck on
 
 RequestExecutionLevel user
 
 !addplugindir ./
 
 Var TmpVal
-Var StartMenuDir
 Var InstallType
 Var AddStartMenuSC
 Var AddQuickLaunchSC
 Var AddDesktopSC
 Var PageName
 
+; By defining NO_STARTMENU_DIR an installer that doesn't provide an option for
+; an application's Start Menu PROGRAMS directory and doesn't define the
+; StartMenuDir variable can use the common InstallOnInitCommon macro.
+!define NO_STARTMENU_DIR
+
 ; On Vista and above attempt to elevate Standard Users in addition to users that
 ; are a member of the Administrators group.
 !define NONADMIN_ELEVATE
 
 ; Disabled until a survey url is provided
 !define AbortSurveyURL "http://live.mozillamessaging.com/survey/cancel/?page="
 
 ; Other included files may depend upon these includes!
@@ -90,28 +94,27 @@ Var PageName
 !include version.nsh
 
 VIAddVersionKey "FileDescription"  "${BrandShortName} Installer"
 VIAddVersionKey "OriginalFilename" "setup.exe"
 
 ; Must be inserted before other macros that use logging
 !insertmacro _LoggingCommon
 
-; Most commonly used macros for managing shortcuts
-!insertmacro _LoggingShortcutsCommon
-
 !insertmacro AddHandlerValues
 !insertmacro ChangeMUIHeaderImage
 !insertmacro CheckForFilesInUse
 !insertmacro CleanUpdatesDir
 !insertmacro CopyFilesFromDir
-!insertmacro FindSMProgramsDir
 !insertmacro GetPathFromString
 !insertmacro GetParent
 !insertmacro IsHandlerForInstallDir
+!insertmacro LogDesktopShortcut
+!insertmacro LogQuickLaunchShortcut
+!insertmacro LogStartMenuShortcut
 !insertmacro ManualCloseAppPrompt
 !insertmacro RegCleanMain
 !insertmacro RegCleanUninstall
 !insertmacro SetBrandNameVars
 !insertmacro UnloadUAC
 !insertmacro WriteRegStr2
 !insertmacro WriteRegDWORD2
 
@@ -166,22 +169,16 @@ Page custom preOptions leaveOptions
 !define MUI_PAGE_CUSTOMFUNCTION_PRE preDirectory
 !define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveDirectory
 !define MUI_DIRECTORYPAGE_VERIFYONLEAVE
 !insertmacro MUI_PAGE_DIRECTORY
 
 ; Custom Shortcuts Page
 Page custom preShortcuts leaveShortcuts
 
-; Start Menu Folder Page Configuration
-!define MUI_PAGE_CUSTOMFUNCTION_PRE preStartMenu
-!define MUI_PAGE_CUSTOMFUNCTION_LEAVE leaveStartMenu
-!define MUI_STARTMENUPAGE_NODISABLE
-!insertmacro MUI_PAGE_STARTMENU Application $StartMenuDir
-
 ; Custom Summary Page
 Page custom preSummary leaveSummary
 
 ; Install Files Page
 !insertmacro MUI_PAGE_INSTFILES
 
 ; Finish Page
 !define MUI_FINISHPAGE_TITLE_3LINES
@@ -292,17 +289,17 @@ Section "-Application" APP_IDX
   ${LogUninstall} "File: \components\compreg.dat"
   ${LogUninstall} "File: \components\xpti.dat"
   ${LogUninstall} "File: \active-update.xml"
   ${LogUninstall} "File: \install.log"
   ${LogUninstall} "File: \install_status.log"
   ${LogUninstall} "File: \install_wizard.log"
   ${LogUninstall} "File: \updates.xml"
 
-  ; Default for creating Start Menu folder and shortcuts
+  ; Default for creating Start Menu shortcut
   ; (1 = create, 0 = don't create)
   ${If} $AddStartMenuSC == ""
     StrCpy $AddStartMenuSC "1"
   ${EndIf}
 
   ; Default for creating Quick Launch shortcut (1 = create, 0 = don't create)
   ${If} $AddQuickLaunchSC == ""
     StrCpy $AddQuickLaunchSC "1"
@@ -386,47 +383,48 @@ Section "-Application" APP_IDX
   ; an install into a different location.
   StrCpy $0 "Software\Microsoft\Windows\CurrentVersion\App Paths\${FileMainEXE}"
   ${WriteRegStr2} $TmpVal "$0" "" "$INSTDIR\${FileMainEXE}" 0
   ${WriteRegStr2} $TmpVal "$0" "Path" "$INSTDIR" 0
 
   ; Create shortcuts
   ${LogHeader} "Adding Shortcuts"
 
-  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
+  ; Remove the start menu shortcuts and directory if the SMPROGRAMS section
+  ; exists in the shortcuts_log.ini and the SMPROGRAMS. The installer's shortcut
+  ; creation code will create the shortcut in the root of the Start Menu
+  ; Programs directory.
+  ${RemoveStartMenuDir}
 
-  ; 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
-  ; exist.
-  ${LogSMProgramsDirRelPath} "$StartMenuDir"
-  ${LogSMProgramsShortcut} "${BrandFullName}.lnk"
-  ${LogSMProgramsShortcut} "${BrandFullName} ($(SAFE_MODE)).lnk"
+  ; Always add the application's shortcuts to the shortcuts log ini file. The
+  ; DeleteShortcuts macro will do the right thing on uninstall if the
+  ; shortcuts don't exist.
+  ${LogStartMenuShortcut} "${BrandFullName}.lnk"
   ${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"
-      ${LogMsg} "Added Start Menu Directory: $SMPROGRAMS\$StartMenuDir"
-    ${EndUnless}
-    CreateShortCut "$SMPROGRAMS\$StartMenuDir\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
+    CreateShortCut "$SMPROGRAMS\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" \
+                   "" "$INSTDIR\${FileMainEXE}" 0
+    ShellLink::SetShortCutWorkingDirectory "$SMPROGRAMS\${BrandFullName}.lnk" \
+                                           "$INSTDIR"
+    ApplicationID::Set "$SMPROGRAMS\${BrandFullName}.lnk" "${AppUserModelID}"
     ${LogMsg} "Added Shortcut: $SMPROGRAMS\$StartMenuDir\${BrandFullName}.lnk"
-    CreateShortCut "$SMPROGRAMS\$StartMenuDir\${BrandFullName} ($(SAFE_MODE)).lnk" "$INSTDIR\${FileMainEXE}" "-safe-mode" "$INSTDIR\${FileMainEXE}" 0
-    ${LogMsg} "Added Shortcut: $SMPROGRAMS\$StartMenuDir\${BrandFullName} ($(SAFE_MODE)).lnk"
   ${EndIf}
 
-  !insertmacro MUI_STARTMENU_WRITE_END
-
   ${If} $AddDesktopSC == 1
-    CreateShortCut "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
+    CreateShortCut "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" \
+                   "" "$INSTDIR\${FileMainEXE}" 0
+    ShellLink::SetShortCutWorkingDirectory "$DESKTOP\${BrandFullName}.lnk" \
+                                           "$INSTDIR"
+    ApplicationID::Set "$DESKTOP\${BrandFullName}.lnk" "${AppUserModelID}"
     ${LogMsg} "Added Shortcut: $DESKTOP\${BrandFullName}.lnk"
   ${EndIf}
 
   ; If elevated the Quick Launch shortcut must be added from the unelevated
   ; original process.
   ${If} $AddQuickLaunchSC == 1
     ClearErrors
     ${GetParameters} $0
@@ -522,18 +520,16 @@ Function CustomAbort
       ${If} "$PageName" == "Welcome"
           GetFunctionAddress $0 AbortSurveyWelcome
       ${ElseIf} "$PageName" == "Options"
           GetFunctionAddress $0 AbortSurveyOptions
       ${ElseIf} "$PageName" == "Directory"
           GetFunctionAddress $0 AbortSurveyDirectory
       ${ElseIf} "$PageName" == "Shortcuts"
           GetFunctionAddress $0 AbortSurveyShortcuts
-      ${ElseIf} "$PageName" == "StartMenu"
-          GetFunctionAddress $0 AbortSurveyStartMenu
       ${ElseIf} "$PageName" == "Summary"
           GetFunctionAddress $0 AbortSurveySummary
       ${EndIf}
       ClearErrors
       ${GetParameters} $1
       ${GetOptions} "$1" "/UAC:" $2
       ${If} ${Errors}
         Call $0
@@ -565,30 +561,30 @@ FunctionEnd
 Function AbortSurveyDirectory
   ExecShell "open" "${AbortSurveyURL}step3"
 FunctionEnd
 
 Function AbortSurveyShortcuts
   ExecShell "open" "${AbortSurveyURL}step4"
 FunctionEnd
 
-Function AbortSurveyStartMenu
+Function AbortSurveySummary
   ExecShell "open" "${AbortSurveyURL}step5"
 FunctionEnd
-
-Function AbortSurveySummary
-  ExecShell "open" "${AbortSurveyURL}step6"
-FunctionEnd
 !endif
 
 ################################################################################
 # Helper Functions
 
 Function AddQuickLaunchShortcut
-  CreateShortCut "$QUICKLAUNCH\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
+  CreateShortCut "$QUICKLAUNCH\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" \
+                 "" "$INSTDIR\${FileMainEXE}" 0
+  ShellLink::SetShortCutWorkingDirectory "$QUICKLAUNCH\${BrandFullName}.lnk" \
+                                         "$INSTDIR"
+  ApplicationID::Set "$QUICKLAUNCH\${BrandFullName}.lnk" "${AppUserModelID}"
 FunctionEnd
 
 Function CheckExistingInstall
   ; If there is a pending file copy from a previous uninstall don't allow
   ; installing until after the system has rebooted.
   IfFileExists "$INSTDIR\${FileMainEXE}.moz-upgrade" +1 +4
   MessageBox MB_YESNO "$(WARN_RESTART_REQUIRED_UPGRADE)" IDNO +2
   Reboot
@@ -731,59 +727,16 @@ Function leaveShortcuts
   ${MUI_INSTALLOPTIONS_READ} $0 "shortcuts.ini" "Settings" "State"
   ${If} $0 != 0
     Abort
   ${EndIf}
   ${MUI_INSTALLOPTIONS_READ} $AddDesktopSC "shortcuts.ini" "Field 2" "State"
   ${MUI_INSTALLOPTIONS_READ} $AddStartMenuSC "shortcuts.ini" "Field 3" "State"
   ${MUI_INSTALLOPTIONS_READ} $AddQuickLaunchSC "shortcuts.ini" "Field 4" "State"
 
-  ; If Start Menu shortcuts won't be created call CheckExistingInstall here
-  ; since leaveStartMenu will not be called.
-  ${If} $AddStartMenuSC != 1
-  ${AndIf} $InstallType == ${INSTALLTYPE_CUSTOM}
-    Call CheckExistingInstall
-  ${EndIf}
-FunctionEnd
-
-Function preStartMenu
-  StrCpy $PageName "StartMenu"
-  ; With the Unicode installer the path to the application's Start Menu
-  ; directory relative to the Start Menu's Programs directory is written to the
-  ; shortcuts log ini file and is used to set the default Start Menu directory.
-  ${GetSMProgramsDirRelPath} $0
-  ${If} "$0" != ""
-    StrCpy $StartMenuDir "$0"
-  ${Else}
-    ; Prior to the Unicode installer the path to the application's Start Menu
-    ; directory relative to the Start Menu's Programs directory was written to
-    ; the registry and use this value to set the default Start Menu directory.
-    ClearErrors
-    ReadRegStr $0 HKLM "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Main" "Start Menu Folder"
-    ${If} ${Errors}
-      ; Use the FindSMProgramsDir macro to find a previously used path to the
-      ; application's Start Menu directory relative to the Start Menu's Programs
-      ; directory in the uninstall log and use this value to set the default
-      ; Start Menu directory.
-      ${FindSMProgramsDir} $0
-      ${If} "$0" != ""
-        StrCpy $StartMenuDir "$0"
-      ${EndIf}
-    ${Else}
-      StrCpy $StartMenuDir "$0"
-    ${EndUnless}
-  ${EndIf}
-
-  ${CheckCustomCommon}
-  ${If} $AddStartMenuSC != 1
-    Abort
-  ${EndIf}
-FunctionEnd
-
-Function leaveStartMenu
   ${If} $InstallType == ${INSTALLTYPE_CUSTOM}
     Call CheckExistingInstall
   ${EndIf}
 FunctionEnd
 
 Function preSummary
   StrCpy $PageName "Summary"
   ; Setup the summary.ini file for the Custom Summary Page
--- a/mail/installer/windows/nsis/shared.nsh
+++ b/mail/installer/windows/nsis/shared.nsh
@@ -90,16 +90,20 @@
     ${If} ${FileExists} "$0"
       ${GetLongPath} "$0" $0
     ${EndIf}
     ${If} "$0" == "$INSTDIR"
       ${SetClientsNews}
     ${EndIf}
   ${EndIf}
 
+  ; Migrate the application's Start Menu directory to a single shortcut in the
+  ; root of the Start Menu Programs directory.
+  ${MigrateStartMenuShortcut}
+
   ${RemoveDeprecatedKeys}
 
   ${SetAppKeys}
   ${SetUninstallKeys}
 
   ; Remove files that may be left behind by the application in the
   ; VirtualStore directory.
   ${CleanVirtualStore}
@@ -160,29 +164,33 @@
 !macroend
 !define HideShortcuts "!insertmacro HideShortcuts"
 
 !macro ShowShortcuts
   StrCpy $R1 "Software\Clients\Mail\${ClientsRegName}\InstallInfo"
   WriteRegDWORD HKLM "$R1" "IconsVisible" 1
   SetShellVarContext all  ; Set $DESKTOP to All Users
   ${Unless} ${FileExists} "$DESKTOP\${BrandFullName}.lnk"
-    CreateShortCut "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
+    CreateShortCut "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" \
+                   "" "$INSTDIR\${FileMainEXE}" 0
     ShellLink::SetShortCutWorkingDirectory "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR"
+    ApplicationID::Set "$DESKTOP\${BrandFullName}.lnk" "${AppUserModelID}"
     ${Unless} ${FileExists} "$DESKTOP\${BrandFullName}.lnk"
       SetShellVarContext current  ; Set $DESKTOP to the current user's desktop
       ${Unless} ${FileExists} "$DESKTOP\${BrandFullName}.lnk"
         CreateShortCut "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
         ShellLink::SetShortCutWorkingDirectory "$DESKTOP\${BrandFullName}.lnk" "$INSTDIR"
+        ApplicationID::Set "$DESKTOP\${BrandFullName}.lnk" "${AppUserModelID}"
       ${EndUnless}
     ${EndUnless}
   ${EndUnless}
   ${Unless} ${FileExists} "$QUICKLAUNCH\${BrandFullName}.lnk"
     CreateShortCut "$QUICKLAUNCH\${BrandFullName}.lnk" "$INSTDIR\${FileMainEXE}" "" "$INSTDIR\${FileMainEXE}" 0
     ShellLink::SetShortCutWorkingDirectory "$QUICKLAUNCH\${BrandFullName}.lnk" "$INSTDIR"
+    ApplicationID::Set "$QUICKLAUNCH\${BrandFullName}.lnk" "${AppUserModelID}"
   ${EndUnless}
 !macroend
 !define ShowShortcuts "!insertmacro ShowShortcuts"
 
 !macro SetHandlersMail
   ${GetLongPath} "$INSTDIR\${FileMainEXE}" $8
   StrCpy $0 "SOFTWARE\Classes"
   StrCpy $1 "$\"$8$\" $\"%1$\""
@@ -551,39 +559,124 @@
   ; Remove the app compatibility registry key
   StrCpy $0 "Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers"
   DeleteRegValue HKLM "$0" "$INSTDIR\${FileMainEXE}"
   DeleteRegValue HKCU "$0" "$INSTDIR\${FileMainEXE}"
 
 !macroend
 !define RemoveDeprecatedKeys "!insertmacro RemoveDeprecatedKeys"
 
+; Adds a shortcut to the root of the Start Menu Programs directory if the
+; application's Start Menu Programs directory exists with a shortcut pointing to
+; this installation directory. This will also remove the old shortcuts and the
+; application's Start Menu Programs directory by calling the RemoveStartMenuDir
+; macro.
+!macro MigrateStartMenuShortcut
+  ${GetShortcutsLogPath} $0
+  ${If} ${FileExists} "$0"
+    ClearErrors
+    ReadINIStr $5 "$0" "SMPROGRAMS" "RelativePathToDir"
+    ${Unless} ${Errors}
+      ClearErrors
+      ReadINIStr $1 "$0" "STARTMENU" "Shortcut0"
+      ${If} ${Errors}
+        ; The STARTMENU ini section doesn't exist.
+        ${LogStartMenuShortcut} "${BrandFullName}.lnk"
+        ${GetLongPath} "$SMPROGRAMS" $2
+        ${GetLongPath} "$2\$5" $1
+        ${If} "$1" != ""
+          ClearErrors
+          ReadINIStr $3 "$0" "SMPROGRAMS" "Shortcut0"
+          ${Unless} ${Errors}
+            ${If} ${FileExists} "$1\$3"
+              ShellLink::GetShortCutTarget "$1\$3"
+              Pop $4
+              ${If} "$INSTDIR\${FileMainEXE}" == "$4"
+                CreateShortCut "$SMPROGRAMS\${BrandFullName}.lnk" \
+                               "$INSTDIR\${FileMainEXE}" "" \
+                               "$INSTDIR\${FileMainEXE}" 0
+                ShellLink::SetShortCutWorkingDirectory "$SMPROGRAMS\${BrandFullName}.lnk" \
+                                                       "$INSTDIR"
+                ApplicationID::Set "$SMPROGRAMS\${BrandFullName}.lnk" \
+                                   "${AppUserModelID}"
+              ${EndIf}
+            ${EndIf}
+          ${EndUnless}
+        ${EndIf}
+      ${EndIf}
+      ; Remove the application's Start Menu Programs directory, shortcuts, and
+      ; ini section.
+      ${RemoveStartMenuDir}
+    ${EndUnless}
+  ${EndIf}
+!macroend
+!define MigrateStartMenuShortcut "!insertmacro MigrateStartMenuShortcut"
+
+; Removes the application's start menu directory along with its shortcuts if
+; they exist and if they exist creates a start menu shortcut in the root of the
+; start menu directory (bug 598779). If the application's start menu directory
+; is not empty after removing the shortucts the directory will not be removed
+; since these additional items were not created by the installer (uses SHCTX).
+!macro RemoveStartMenuDir
+  ${GetShortcutsLogPath} $0
+  ${If} ${FileExists} "$0"
+    ; Delete Start Menu Programs shortcuts, directory if it is empty, and
+    ; parent directories if they are empty up to but not including the start
+    ; menu directory.
+    ${GetLongPath} "$SMPROGRAMS" $1
+    ClearErrors
+    ReadINIStr $2 "$0" "SMPROGRAMS" "RelativePathToDir"
+    ${Unless} ${Errors}
+      ${GetLongPath} "$1\$2" $2
+      ${If} "$2" != ""
+        ; Delete shortucts in the Start Menu Programs directory.
+        StrCpy $3 0
+        ${Do}
+          ClearErrors
+          ReadINIStr $4 "$0" "SMPROGRAMS" "Shortcut$3"
+          ; Stop if there are no more entries
+          ${If} ${Errors}
+            ${ExitDo}
+          ${EndIf}
+          ${If} ${FileExists} "$2\$4"
+            ShellLink::GetShortCutTarget "$2\$4"
+            Pop $5
+            ${If} "$INSTDIR\${FileMainEXE}" == "$5"
+              Delete "$2\$4"
+            ${EndIf}
+          ${EndIf}
+          IntOp $3 $3 + 1 ; Increment the counter
+        ${Loop}
+        ; Delete Start Menu Programs directory and parent directories
+        ${Do}
+          ; Stop if the current directory is the start menu directory
+          ${If} "$1" == "$2"
+            ${ExitDo}
+          ${EndIf}
+          ClearErrors
+          RmDir "$2"
+          ; Stop if removing the directory failed
+          ${If} ${Errors}
+            ${ExitDo}
+          ${EndIf}
+          ${GetParent} "$2" $2
+        ${Loop}
+      ${EndIf}
+      DeleteINISec "$0" "SMPROGRAMS"
+    ${EndUnless}
+  ${EndIf}
+!macroend
+!define RemoveStartMenuDir "!insertmacro RemoveStartMenuDir"
+
 ; Creates the shortcuts log ini file with the appropriate entries if it doesn't
 ; already exist.
 !macro CreateShortcutsLog
   ${GetShortcutsLogPath} $0
   ${Unless} ${FileExists} "$0"
-    ; Default to ${BrandFullName} for the Start Menu Folder
-    StrCpy $TmpVal "${BrandFullName}"
-    ; Prior to Unicode installer the Start Menu directory was written to the
-    ; registry and this value can be used to set the Start Menu directory.
-    ClearErrors
-    ReadRegStr $0 SHCTX "Software\Mozilla\${BrandFullNameInternal}\${AppVersion} (${AB_CD})\Main" "Start Menu Folder"
-    ${If} ${Errors}
-      ${FindSMProgramsDir} $0
-      ${If} "$0" != ""
-        StrCpy $TmpVal "$0"
-      ${EndIf}
-    ${Else}
-      StrCpy $TmpVal "$0"
-    ${EndUnless}
-
-    ${LogSMProgramsDirRelPath} "$TmpVal"
-    ${LogSMProgramsShortcut} "${BrandFullName}.lnk"
-    ${LogSMProgramsShortcut} "${BrandFullName} ($(SAFE_MODE)).lnk"
+    ${LogStartMenuShortcut} "${BrandFullName}.lnk"
     ${LogQuickLaunchShortcut} "${BrandFullName}.lnk"
     ${LogDesktopShortcut} "${BrandFullName}.lnk"
   ${EndUnless}
 !macroend
 !define CreateShortcutsLog "!insertmacro CreateShortcutsLog"
 
 ; The MAPI DLL's are copied and the copies are used for the MAPI registration
 ; to lessen file in use errors on application update.
--- a/mail/installer/windows/nsis/uninstaller.nsi
+++ b/mail/installer/windows/nsis/uninstaller.nsi
@@ -91,25 +91,27 @@ VIAddVersionKey "FileDescription"  "${Br
 VIAddVersionKey "OriginalFilename" "helper.exe"
 
 ; Most commonly used macros for managing shortcuts
 !insertmacro _LoggingShortcutsCommon
 
 !insertmacro AddHandlerValues
 !insertmacro CleanVirtualStore
 !insertmacro ElevateUAC
-!insertmacro FindSMProgramsDir
 !insertmacro GetLongPath
 !insertmacro GetPathFromString
 !insertmacro IsHandlerForInstallDir
+!insertmacro LogDesktopShortcut
+!insertmacro LogQuickLaunchShortcut
+!insertmacro LogStartMenuShortcut
 !insertmacro RegCleanMain
 !insertmacro RegCleanUninstall
 !insertmacro SetBrandNameVars
 !insertmacro UnloadUAC
-!insertmacro UpdateShortcutAppModelIDs
+!insertmacro UpdateShortcutAppModelIDs
 !insertmacro WriteRegDWORD2
 !insertmacro WriteRegStr2
 
 !insertmacro un.ChangeMUIHeaderImage
 !insertmacro un.CheckForFilesInUse
 !insertmacro un.CleanUpdatesDir
 !insertmacro un.CleanVirtualStore
 !insertmacro un.DeleteShortcuts