Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 0b45d0c

Browse files
committed
Bug 1730290 - Replace $LocalAppData in NSIS. r=bytesized,mhowell
1. $LocalAppData behavior changes in NSIS 3.02, previously it always used CSIDL_LOCAL_APPDATA but it now depends on context, work around that by directly calling SHGetSpecialFolderPathW. 2. Refactor several other calls to SHGetSpecialFolderPathW for CSIDL_COMMON_APPDATA and CSIDL_PROGRAMS. 3. Remove broken default path fallback to $APPDATA. I was in this code for 1. and realized it hadn't worked properly in the full installer since bug 367539, and it must have never worked in the stub. 4. Remove unused CleanUpdateDirectories and DeleteRelativeProfiles macros rather than trying to fix them. Differential Revision: https://phabricator.services.mozilla.com/D125490
1 parent e7005dd commit 0b45d0c

5 files changed

Lines changed: 79 additions & 272 deletions

File tree

browser/installer/windows/nsis/installer.nsi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,8 @@ Function WriteInstallationTelemetryData
12621262

12631263
; Check for top-level profile directory
12641264
; Note: This is the same check used to set $ExistingProfile in stub.nsi
1265-
${If} ${FileExists} "$LOCALAPPDATA\Mozilla\Firefox"
1265+
${GetLocalAppDataFolder} $0
1266+
${If} ${FileExists} "$0\Mozilla\Firefox"
12661267
StrCpy $1 "true"
12671268
${Else}
12681269
StrCpy $1 "false"

browser/installer/windows/nsis/shared.nsh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,9 +417,8 @@ ${RemoveDefaultBrowserAgentShortcut}
417417
Push $2
418418
Push $3
419419

420-
; 2 is CSIDL_PROGRAMS, it's simpler to use this to get the user's Start Menu Programs than
421-
; to use $SMPROGRAMS and rely on SetShellVarContext current.
422-
System::Call "Shell32::SHGetSpecialFolderPathW(p 0, t.r1, i 2, i 0)"
420+
; Get the current user's Start Menu Programs.
421+
${GetProgramsFolder} $1
423422

424423
; The shortcut would have been named MOZ_BASE_NAME regardless of branding.
425424
; According to defines.nsi.in AppName should match application.ini, and application.ini.in sets

browser/installer/windows/nsis/stub.nsi

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -429,21 +429,13 @@ Function .onInit
429429

430430
SetShellVarContext all ; Set SHCTX to All Users
431431
; If the user doesn't have write access to the installation directory set
432-
; the installation directory to a subdirectory of the All Users application
433-
; directory and if the user can't write to that location set the installation
434-
; directory to a subdirectory of the users local application directory
435-
; (e.g. non-roaming).
432+
; the installation directory to a subdirectory of the user's local
433+
; application directory (e.g. non-roaming).
436434
Call CanWrite
437435
${If} "$CanWriteToInstallDir" == "false"
438-
StrCpy $INSTDIR "$APPDATA\${BrandFullName}\"
436+
${GetLocalAppDataFolder} $0
437+
StrCpy $INSTDIR "$0\${BrandFullName}\"
439438
Call CanWrite
440-
${If} "$CanWriteToInstallDir" == "false"
441-
; This should never happen but just in case.
442-
StrCpy $CanWriteToInstallDir "false"
443-
${Else}
444-
StrCpy $INSTDIR "$LOCALAPPDATA\${BrandFullName}\"
445-
Call CanWrite
446-
${EndIf}
447439
${EndIf}
448440

449441
Call CheckSpace
@@ -692,7 +684,8 @@ Function createInstall
692684
StrCpy $ExistingBuildID "0"
693685
${EndIf}
694686

695-
${If} ${FileExists} "$LOCALAPPDATA\Mozilla\Firefox"
687+
${GetLocalAppDataFolder} $0
688+
${If} ${FileExists} "$0\Mozilla\Firefox"
696689
StrCpy $ExistingProfile "1"
697690
${Else}
698691
StrCpy $ExistingProfile "0"

browser/installer/windows/nsis/uninstaller.nsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ Function un.GetCommonDirectory
332332
Push $0 ; Save $0
333333

334334
; This gets C:\ProgramData or the equivalent.
335-
; 0x23 is CSIDL_COMMON_APPDATA, see CreateUpdateDir in common.nsh.
336-
System::Call "Shell32::SHGetSpecialFolderPathW(p 0, t.r0, i 0x23, i 0)"
335+
${GetCommonAppDataFolder} $0
336+
337337
; Add our subdirectory, this is hardcoded as grandparent of the update directory in
338338
; several other places.
339339
StrCpy $0 "$0\Mozilla"

0 commit comments

Comments
 (0)