Archive: Defining InstallDir interactively ???


Defining InstallDir interactively ???
Depending on the answer of the user I want to assign the final InstallDir interactively.

As far as I understand the function
.onInit is called prior to ALL (other) Sections.
Is this correct?

Are there any restrictions for this .onInit function ?
Read: Can I put something like the following code into
the .onInit function (ignore possible line wraps) and access later
the contents of InstallDir ??

Function .onInit
...
MessageBox MB_YESNO|MB_ICONQUESTION "Do you want to install version A? IDNO LabelB
InstallDir "C:\project\pathA"
Goto continue
LabelB:
InstallDir "C:\project\pathB"

continue:
....
FunctionEnd

Section "mystuff"
SetOutPath $INSTDIR ; Path from above should be assigned
....


Yes, .onInit is called prior to any other code in the installer. Your code should theoretically work, all you need to do is replace InstallDir with StrCpy $INSTDIR C:\something.

I recommend you use a nice InstallOption page to let the user choose.


Not working !!
The code is NOT working!!!!
I am getting an error message when I compile the script

Error: command InstallDir not valid in function

Why ?

Is it possible to code

StrCpy $INSTDIR "C:\myproject"

?

Would this be equal to the InstallDir command ?


As I said you have to replace it. InstallDir just defines the initial value of $INSTDIR, which can be later overriden with StrCpy $INSTDIR C:\something. InstallDir can only be used outside of sections and function, StrCpy can only be used inside sections or functions.