from time to time I encounter issues while performing a backup of the current $INSTDIR during the upgrade process.
In order to make sure that everything is closed and nothing blocks the move process, I am first closing everything that I know of and then, just to make sure, running LockedList on $INSTDIR and closing everything else that might still be open (like log files, for example).
Here are the functions I am using:
Then, in another function (that moves the existing folder), I use this:Function SilentSearchCallback
Pop $R0
Pop $R1
Pop $R2
${If} $R0 == -1
DetailPrint "ERROR: Could not close locked process: $R2!"
${Else}
DetailPrint "INFO: Closing locked process: $R2"
Push autoclose
${EndIf}
FunctionEnd
Function CloseLockedFiles
LockedList::AddFolder $INSTDIR
GetFunctionAddress $R0 SilentSearchCallback
LockedList::SilentSearch $R0
Pop $R0
DetailPrint $R0
SetAutoClose false
FunctionEnd
I then perform the following test:Detailprint "Prior installation will be moved to $FinalBackupPriorInstallationFolder"
Call CloseLockedFiles
Rename "$INSTDIR" "${TEMP_BACKUP_FOLDER}\ImageDiagnost"
IfErrors 0 move_to_temp_success
; Abort on error - some files are locked
${myLogText} "ERROR: Backup of prior installation files failed!"
${myLogText} "ERROR: Cannot move from $INSTDIR to ${TEMP_BACKUP_FOLDER}\ImageDiagnost"
${myLogText} "ERROR: Update installation aborted. Your existing installation is untouched."
abort "Update installation aborted. Your existing installation is untouched."
- Start an executable in $INSTDIR (ex: putty)
- Open a log file (text file) from the $INSTDIR
- Have a folder from $INSTDIR open in Windows Explorer
- Run my installer
While executing the installer, putty.exe is closed, Notepad is closed (with the log file) but then the Rename command fails.
If at this point I try to rename the folder manually, it works!. The problem seems to be with renaming through NSIS. The folder where I try to move does not exist so there is nothing to overwrite.
Any idea why this might be happening? Could it be because I have a Windows Explorer open and NSIS has some trouble with that?
Thank you!