Skip to content

Commit

Permalink
Delete installation directory only if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
isaak654 committed Jun 16, 2023
1 parent e4a6bda commit c68bbf7
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions Sandboxie/install/SandboxieVS.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -849,10 +849,10 @@ Function CheckUpdates
DoCheck:
DetailPrint "Running UpdUtil ..."
SetDetailsPrint listonly

ExecWait '"$INSTDIR\UpdUtil.exe" $0 sandboxie /step:scan /scope:meta /version:${VERSION}' $1
;MessageBox MB_OK "UpdUtil: $0"

IntCmp $1 0 is0 lessthan0 morethan0
is0:
;DetailPrint "no update"
Expand All @@ -863,12 +863,12 @@ DoCheck:
morethan0:
DetailPrint "$$0 > 5"
Goto Update

Update:
MessageBox MB_YESNO|MB_ICONQUESTION "$(MSG_8055)" IDNO NoUpdate

ExecWait '"$INSTDIR\UpdUtil.exe" $0 sandboxie /step:apply /scope:meta'

NoUpdate:
SetDetailsPrint both
FunctionEnd
Expand Down Expand Up @@ -1150,6 +1150,27 @@ SkipCopyInstaller:

FunctionEnd

;----------------------------------------------------------------------------
; Function DeleteDirIfEmpty
;----------------------------------------------------------------------------

Function DeleteDirIfEmpty

FindFirst $R0 $R1 "$0\*.*"
strcmp $R1 "." 0 NoDelete
FindNext $R0 $R1
strcmp $R1 ".." 0 NoDelete
ClearErrors
FindNext $R0 $R1
IfErrors 0 NoDelete
FindClose $R0
Sleep 1000
RMDir "$0"
NoDelete:
FindClose $R0

FunctionEnd

;----------------------------------------------------------------------------
; Function DeleteProgramFiles
;----------------------------------------------------------------------------
Expand Down Expand Up @@ -1183,7 +1204,7 @@ Function DeleteProgramFiles

Delete "$INSTDIR\KmdUtil.exe"
Delete "$INSTDIR\UpdUtil.exe"

Delete "$INSTDIR\SboxHostDll.dll"

Delete "$INSTDIR\boxHostDll.dll"
Expand Down Expand Up @@ -1250,10 +1271,11 @@ Function DeleteProgramFiles
SkipDeleteSandboxieIni:

;
; Delete installation folder
; Delete installation folder if empty
;

RMDir "$INSTDIR"
StrCpy $0 "$INSTDIR"
Call DeleteDirIfEmpty

FunctionEnd

Expand Down

0 comments on commit c68bbf7

Please sign in to comment.