Prev Previous Post   Next Post Next
Old 19th August 2014, 09:33   #1
Mircea M
Junior Member
 
Join Date: Aug 2014
Posts: 44
Weird behaviour of "Rename" command

Hi,

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:

code:
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



Then, in another function (that moves the existing folder), I use this:

code:
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."



I then perform the following test:
  1. Start an executable in $INSTDIR (ex: putty)
  2. Open a log file (text file) from the $INSTDIR
  3. Have a folder from $INSTDIR open in Windows Explorer
  4. 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!
Mircea M is offline   Reply With Quote
 
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump