c567591
15th August 2005 22:28 UTC
SetOverwrite
I am trying to use set overwrite and I am having 2 problems:
1) If I set the file date on a file in the OS to the current time and then rerun the installer with SetOverwrite IfNewer, then it is being overwritten anyway. :(
2) Here is a section that I am tring to add a commandline variable to override SetOverwrite:
${If} $R0 == ""
SetOverwrite On
MessageBox MB_OK "*** Warning: File overwrite mode is ON. All files will be overwritten!"
DetailPrint "*** Warning: File overwrite mode is ON. All files will be overwritten!"
LogText "*** Warning: File overwrite mode is ON. All files will be overwritten!"
${Else}
SetOverwrite IfNewer ;Set for regular install
MessageBox MB_OK "File overwrite mode is set to Update."
DetailPrint "File overwrite mode is set to Update."
LogText "File overwrite mode is set to Update."
${EndIf}
I only see 1 message box based on if I have the commandline parameter there or not.
That part works, the SetOverwrite does not seem to change.
What I am trying to acomplish here is to add a switch for our support to use to force overwrite of all items regardless of the dates/versions.
I searched and found similar problems but not exactly the same as these.
Comperio
16th August 2005 01:06 UTC
If I'm not mistaken, SetOverwrite is a compile-time command (since it's used in conjunction with the FILE command.)
Assuming that, you may need to create 2 separate sections--one to execute with the command line switch in place and the other when it's not. (The file commands themselves could be wrapped in a macro so that you could re-use the same FILE commands in both sections without having to re-write a lot of the code.)
JasonFriday13
16th August 2005 04:23 UTC
I was thinking of using 'strcpy $(^SetOverWrite) on' or 'strcpy $(^SetOverWrite) ifnewer' for run-time assigning. I don't know if this will work, it is just an idea I got during the development of the installer for my UI (User Interface).
c567591
16th August 2005 15:14 UTC
I still don't think that would get around the double file listings.
Is there an alternative to a double file listing?
Comperio
16th August 2005 15:25 UTC
Let's say that the overwrite flag is stored in $R1. ("Y" means overwrite, 'N' means no overwrite) Put your file copies in a macro like this:
!macro InstallFiles
File 'C:\myfile1.dat'
File 'C:\myfile2.dat'
; [add more files here]
!macroend
Next, create your two sections like this:
Section '-WithOverwriteOn'
; this section gets processes only when
; overwrite flag is on...
StrCmp $R1 'N' endsection 0
SetOverwrite on
SetOutPath 'C:\somedirectory'
!insertmacro InstallFiles
endsection:
SectionEnd
Section '-WithOverwriteOff'
; this section gets processes only when
; overwrite flag is off...
StrCmp $R1 'Y' endsection 0
SetOverwrite IfNewer
SetOutPath 'C:\somedirectory'
!insertmacro InstallFiles
endsection:
SectionEnd