Handle app running

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@7261 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
anders_k 2021-02-16 13:47:25 +00:00
parent 62b5ca2dba
commit 2a0db8b42e
2 changed files with 28 additions and 9 deletions

View file

@ -11,7 +11,7 @@ folders inside the users profile.
*/ */
!define NAME "Per-User example" !define NAME "Per-user example"
!define REGPATH_UNINSTSUBKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" !define REGPATH_UNINSTSUBKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
Name "${NAME}" Name "${NAME}"
OutFile "Install ${NAME}.exe" OutFile "Install ${NAME}.exe"
@ -48,6 +48,7 @@ Function un.onInit
SetShellVarContext Current SetShellVarContext Current
FunctionEnd FunctionEnd
Section "Program files (Required)" Section "Program files (Required)"
SectionIn Ro SectionIn Ro
@ -161,12 +162,20 @@ Section -un.ShellAssoc
${NotifyShell_AssocChanged} ${NotifyShell_AssocChanged}
SectionEnd SectionEnd
Section -Uninstall !macro DeleteFileOrAskAbort path
${UnpinShortcut} "$SMPrograms\${NAME}.lnk" ClearErrors
Delete "$SMPrograms\${NAME}.lnk" Delete "${path}"
IfErrors 0 +3
MessageBox MB_ABORTRETRYIGNORE|MB_ICONSTOP 'Unable to delete "${path}"!' IDRETRY -3 IDIGNORE +2
Abort "Aborted"
!macroend
Delete "$InstDir\MyApp.exe" Section -Uninstall
!insertmacro DeleteFileOrAskAbort "$InstDir\MyApp.exe"
Delete "$InstDir\Uninst.exe" Delete "$InstDir\Uninst.exe"
RMDir "$InstDir" RMDir "$InstDir"
DeleteRegKey HKCU "${REGPATH_UNINSTSUBKEY}" DeleteRegKey HKCU "${REGPATH_UNINSTSUBKEY}"
${UnpinShortcut} "$SMPrograms\${NAME}.lnk"
Delete "$SMPrograms\${NAME}.lnk"
SectionEnd SectionEnd

View file

@ -24,12 +24,14 @@ InstallDirRegKey HKLM "${REGPATH_UNINSTSUBKEY}" "UninstallString"
!include LogicLib.nsh !include LogicLib.nsh
!include Integration.nsh !include Integration.nsh
Page Directory Page Directory
Page InstFiles Page InstFiles
Uninstpage UninstConfirm Uninstpage UninstConfirm
Uninstpage InstFiles Uninstpage InstFiles
!macro EnsureAdminRights !macro EnsureAdminRights
UserInfo::GetAccountType UserInfo::GetAccountType
Pop $0 Pop $0
@ -74,12 +76,20 @@ Section "Start Menu shortcut"
SectionEnd SectionEnd
Section -Uninstall !macro DeleteFileOrAskAbort path
${UnpinShortcut} "$SMPrograms\${NAME}.lnk" ClearErrors
Delete "$SMPrograms\${NAME}.lnk" Delete "${path}"
IfErrors 0 +3
MessageBox MB_ABORTRETRYIGNORE|MB_ICONSTOP 'Unable to delete "${path}"!' IDRETRY -3 IDIGNORE +2
Abort "Aborted"
!macroend
Delete "$InstDir\MyApp.exe" Section -Uninstall
!insertmacro DeleteFileOrAskAbort "$InstDir\MyApp.exe"
Delete "$InstDir\Uninst.exe" Delete "$InstDir\Uninst.exe"
RMDir "$InstDir" RMDir "$InstDir"
DeleteRegKey HKLM "${REGPATH_UNINSTSUBKEY}" DeleteRegKey HKLM "${REGPATH_UNINSTSUBKEY}"
${UnpinShortcut} "$SMPrograms\${NAME}.lnk"
Delete "$SMPrograms\${NAME}.lnk"
SectionEnd SectionEnd