Archive: SetOverwrite scope


SetOverwrite scope
Hi,

I just started doing NSIS installer, and there is one thing that I cannot understand...

I have a custom window where I can select if I should do a new installation (SetOverwrite on) or an update (SetOverwrite off) for some files. This is working great.

But SetOverwrite on/off doesn't seems to be working always.

This doesnt work even if MessageBoxes confirm that the correct SetOverwrite was done:


Section "!Section 1"
SetOutPath $INSTDIR
SetOverwrite on
; Recreate everything BUT web.config
File /a /r /x "web.config" "${SRCDIR}\*.*"
SectionEnd

Section "Section 2"
SetOutPath $INSTDIR

${If} $SETUP_MODE == "1"
SetOverwrite off ; Don't overwrite present files
${ElseIf} $SETUP_MODE == "0"
SetOverwrite on
${EndIf}

; This overwrite my file, even if I just wrote into it (INSTDIR)!
File "${SRCDIR}\web.config"
SectionEnd


It works if I do one of the folowing:


${If} $SETUP_MODE == "1"
SetOverwrite off ; Don't overwrite present files
File "${SRCDIR}\web.config"
${ElseIf} $SETUP_MODE == "0"
SetOverwrite on
File "${SRCDIR}\web.config"
${EndIf}


Or it works (as it should) if I do this:

SetOverwrite off
File "${SRCDIR}\web.config"

--

So, What is the scope of SetOverwrite ???

I'm still reading and trying many ways, but nothing I do work correctly... But as I was reading the manual, could all those problems be explained by the fact that SetOverwrite is a compiler flag and not an instruction ?

If so.... it kind of s*cks no ?


yea, setoverwrite is interpreted by the compiler and thus the setting is hardwritten into the installer on compile time.

setoverwrite is not used on runtime so you can't use it to change the overwrite mode during installation.


Thanks for the information. So there is no other way to set this overwrite at runtime ?

Hoping my other code constructs will still work ok !