Skip to content

Commit

Permalink
fix(nsis): finally — NSIS Installer Not Working on Second Invocation
Browse files Browse the repository at this point in the history
Closes #722
  • Loading branch information
develar committed Sep 7, 2016
1 parent 2e35205 commit 211d63f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
31 changes: 23 additions & 8 deletions templates/nsis/installSection.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,31 @@ ${endif}
${endif}
!endif

ReadRegStr $R0 SHCTX "${UNINSTALL_REGISTRY_KEY}" UninstallString
# http://stackoverflow.com/questions/24595887/waiting-for-nsis-uninstaller-to-finish-in-nsis-installer-either-fails-or-the-uni

ReadRegStr $R0 SHCTX "${UNINSTALL_REGISTRY_KEY}" UninstallerPath
${if} $R0 != ""
ExecWait "$R0 /S /KEEP_APP_DATA"
ReadRegStr $R1 SHCTX "${INSTALL_REGISTRY_KEY}" InstallLocation
${if} $R1 != ""
CopyFiles /SILENT /FILESONLY "$R0" "$PLUGINSDIR\old-uninstaller.exe"

${if} $installMode == "all"
ExecWait "$PLUGINSDIR\old-uninstaller.exe _?=$R1 /S /KEEP_APP_DATA /allusers"
${Else}
ExecWait "$PLUGINSDIR\old-uninstaller.exe _?=$R1 /S /KEEP_APP_DATA /currentuser"
${endif}
${endif}
${endif}

# remove per-user installation
${if} $installMode == "all"
# remove per-user installation
ReadRegStr $R0 HKEY_CURRENT_USER "${UNINSTALL_REGISTRY_KEY}" UninstallString
ReadRegStr $R0 HKEY_CURRENT_USER "${UNINSTALL_REGISTRY_KEY}" UninstallerPath
${if} $R0 != ""
ExecWait "$R0 /S /KEEP_APP_DATA"
ReadRegStr $R1 HKEY_CURRENT_USER "${INSTALL_REGISTRY_KEY}" InstallLocation
${if} $R1 != ""
CopyFiles /SILENT /FILESONLY "$R0" "$PLUGINSDIR\old-uninstaller.exe"
ExecWait "$PLUGINSDIR\old-uninstaller.exe _?=$R1 /S /KEEP_APP_DATA /currentuser"
${endif}
${endif}
${endif}

Expand All @@ -50,12 +65,12 @@ SetCompress "${COMPRESS}"

!ifdef APP_64
${If} ${RunningX64}
Nsis7z::ExtractWithDetails "$PLUGINSDIR\app-64.7z" "Installing %s..."
Nsis7z::Extract "$PLUGINSDIR\app-64.7z"
${Else}
Nsis7z::ExtractWithDetails "$PLUGINSDIR\app-32.7z" "Installing %s..."
Nsis7z::Extract "$PLUGINSDIR\app-32.7z"
${endif}
!else
Nsis7z::ExtractWithDetails "$PLUGINSDIR\app-32.7z" "Installing %s..."
Nsis7z::Extract "$PLUGINSDIR\app-32.7z"
!endif

File "/oname=${UNINSTALL_FILENAME}" "${UNINSTALLER_OUT_FILE}"
Expand Down
1 change: 1 addition & 0 deletions templates/nsis/multiUser.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Var installMode
WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" DisplayName "${UNINSTALL_DISPLAY_NAME} (only current user)"
WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" UninstallString '"$INSTDIR\${UNINSTALL_FILENAME}" /currentuser'
${endif}
WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" UninstallerPath '"$INSTDIR\${UNINSTALL_FILENAME}"'

WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayVersion" "${VERSION}"
WriteRegStr SHCTX "${UNINSTALL_REGISTRY_KEY}" "DisplayIcon" "$appExe,0"
Expand Down

0 comments on commit 211d63f

Please sign in to comment.