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}"
Name "${NAME}"
OutFile "Install ${NAME}.exe"
@ -48,6 +48,7 @@ Function un.onInit
SetShellVarContext Current
FunctionEnd
Section "Program files (Required)"
SectionIn Ro
@ -161,12 +162,20 @@ Section -un.ShellAssoc
${NotifyShell_AssocChanged}
SectionEnd
Section -Uninstall
${UnpinShortcut} "$SMPrograms\${NAME}.lnk"
Delete "$SMPrograms\${NAME}.lnk"
!macro DeleteFileOrAskAbort path
ClearErrors
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"
RMDir "$InstDir"
DeleteRegKey HKCU "${REGPATH_UNINSTSUBKEY}"
${UnpinShortcut} "$SMPrograms\${NAME}.lnk"
Delete "$SMPrograms\${NAME}.lnk"
SectionEnd

View file

@ -24,12 +24,14 @@ InstallDirRegKey HKLM "${REGPATH_UNINSTSUBKEY}" "UninstallString"
!include LogicLib.nsh
!include Integration.nsh
Page Directory
Page InstFiles
Uninstpage UninstConfirm
Uninstpage InstFiles
!macro EnsureAdminRights
UserInfo::GetAccountType
Pop $0
@ -74,12 +76,20 @@ Section "Start Menu shortcut"
SectionEnd
Section -Uninstall
${UnpinShortcut} "$SMPrograms\${NAME}.lnk"
Delete "$SMPrograms\${NAME}.lnk"
!macro DeleteFileOrAskAbort path
ClearErrors
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"
RMDir "$InstDir"
DeleteRegKey HKLM "${REGPATH_UNINSTSUBKEY}"
${UnpinShortcut} "$SMPrograms\${NAME}.lnk"
Delete "$SMPrograms\${NAME}.lnk"
SectionEnd