Locked Folders
The code below works correctly until the very end when it calls the macro to delete the c:\tempunzip folder that it created to unzip the files to.
If I try to delete the folder manually whilst the installer is still open it says it is locked so the NSIS installer is obviously holding it. I know I can set the /reboot flag for rmdir but it is not convenient for this instance.
Can anyone see any reason in the code below why the c:\tempunzip folder would be locked? Is it the 7zip process?
ShowInstDetails show
!include 'nsdialogs.nsh'
!include 'nsdialogs_setimageole.nsh'
!include "FileFunc.nsh"
!include "Locate.nsh"
!include "Sections.nsh"
!include "CharStrip.nsh"
!insertmacro Locate
Var Text
Var Text2
Var Text3
Var PathForInstallLabel
Var PathForInstallFileRequest
Var PathForInstallGroupBox
Var PathForInstallFileBrowse
Var PathForInstallFileRequestState
Function .onInit
InitPluginsDir
SetOutPath $PLUGINSDIR
File logo.jpg
File 7za.exe
FunctionEnd
Page Custom CustomPre
Page instfiles
Function CustomPre
nsDialogs::Create 1018
Pop $R0
${If} $Dialog == error
Abort
${EndIf}
${NSD_CreateBitmap} 280 10 100 100 ""
Pop $0
; You should make sure the resource - local or http - is valid!
${NSD_SetImageOLE} $0 "$PLUGINSDIR\logo.jpg" $1
${NSD_CreateLabel} 10 10 300 100 "Welcome To the program"
Pop $Text
CreateFont $0 "Arial Bold" 12
SendMessage $Text ${WM_SETFONT} $0 1
${NSD_CreateLabel} 10 35 300 20 "Select a zip file and press next"
Pop $Text2
${NSD_CreateLabel} 10 50 300 20 "It will then be processed"
Pop $Text3
; Create Controls
${NSD_CreateGroupBox} 0 0 100% 100% ""
Pop $PathForInstallGroupBox
${NSD_CreateLabel} 16 170 280 24 "Please select the install file, and click next to continue"
Pop $PathForInstallLabel
${NSD_CreateFileRequest} 10u 86u 245u 12u $PathForInstallFileRequestState
Pop $PathForInstallFileRequest
${NSD_CreateBrowseButton} 358 166 25 22 "..."
Pop $PathForInstallFileBrowse
GetFunctionAddress $0 OnBrowseForFile
nsDialogs::OnClick /NOUNLOAD $PathForInstallFileBrowse $0
nsDialogs::Show
${NSD_FreeImageOLE} $1 ; Free the image once we're done with it!
FunctionEnd
Function OnBrowseForFile
nsDialogs::SelectFileDialog /NOUNLOAD "open" "" "All files (*.*)|*.*"
Pop $0
StrCpy $PathForInstallFileRequestState $0
${NSD_SetText} $PathForInstallFileRequest $PathForInstallFileRequestState
FunctionEnd
!macro unzip
CreateDirectory "c:\tempunzip"
nsexec::exectolog '"$EXEDIR\7za.exe" x "$0" -y -o"c:\tempunzip"'
${Locate} "C:\tempunzip" "/M=.DS_Store" "LocateCallback"
${locate} "C:\tempunzip" "/L=D /M=__MACOSX" "LocateCallbackFolder"
!macroend
!macro zip
${StrStrip} ".zip" "$0" $R0
nsexec::exectolog '"$EXEDIR\7za.exe" a -r "$R0_CLEAN.zip" "c:\tempunzip\*.*"'
!macroend
!macro delete
SetOutpath $TEMP
RMdir /r "c:\tempunzip"
!macroend
Function LocateCallback
Delete $R9
Push $0
FunctionEnd
Function LocateCallbackFolder
RMDir /r $R9
Push $0
FunctionEnd
Section
!insertmacro unzip
!insertmacro zip
!insertmacro delete
SectionEnd