Rename function and multiple hard drives
I am having a problem with the Rename command in NSIS. Here is my code:
;-----------------------------------------
; CopyLockedFile
;-----------------------------------------
; Attempts to copy a file. If the file could not be copied, then
; the file is copied to a temporary location and copied to
; its proper directory after a reboot.
;-----------------------------------------
!macro CopyLockedFile FILE_NAME OUTPUT_PATH LOCAL_PATH
Push $R1
ClearErrors
; Try to copy the file.
SetOutPath ${OUTPUT_PATH}
SetOverwrite Try
File "${LOCAL_PATH}\${FILE_NAME}"
SetOverwrite On
; If we got an error copying, then the file was in use.
IfErrors FileNotCopied ExitOut
; The file could not be copied, most likely because it was in use.
FileNotCopied:
; Create a temporary file. The name of this file will be unique.
; The name will be stored in $R1.
GetTempFileName $R1
; Copy the output file over the temporary file we just created.
; For example, this would copy asteel2.exe to j2iofawer.atj (or some other unique temp file name).
File /oname=$R1 "${LOCAL_PATH}\${FILE_NAME}"
; Rename and copy the temp file ($R1) to the actual destination, renaming it to the proper name.
; If a reboot is required (probably always), set the reboot flag.
Rename /REBOOTOK $R1 "${OUTPUT_PATH}\${FILE_NAME}"
ExitOut:
Pop $R1
!macroend
And I call the function like so:
Section
!insertmacro CopyLockedFile qrpt60.bpl $INSTDIR\SYSTEM "${FilesDir}"
SectionEnd
Let's say I install on the C: drive on my Windows 2000 machine in some folder, launch my application (let's call it text.exe), then reinstall while my application is open. This is fine - test.exe is locked by the system because it is running, so based on the above code a temp file will be created and during the next reboot test.exe will be updated. This works great (except for the LFN/Win95 issue that I posted elsewhere).
Here is my problem. If I follow the same steps as above but do so on my D: drive, the files never get updated on reboot. What might cause this? How does Windows know to update files on reboot anyway (registry, ini file)?