MysticHead
8th December 2004 17:51 UTC
$INSTDIR > InstallDir ?
Hello,
I've been reading the forums/archive/manual and I haven't been able to find the answer to this question, though search results are often a bit overwhelming so maybe I missed it... sorry if that's the case.
Does $INSTDIR take precidence over InstallDir?
The documentation talks about InstallDir setting the default directory. Does that mean that InstallDir is ONLY used if $INSTDIR is NOT set?
It seems to work this way, but I wanted to clarify that it was the intent and not simply that my script was written in such a way as to make it look like this was happening.
I've used VenisIX to get my basic script, and then I've continued to modify it. I'm using .onInit to set the value of $INSTDIR to C:\3rdPartyAppDir\myApp but I just realized that after the funcion end, in "main installer settings" InstalDir is being set to $PROGRAMFILES\myApp
As I said everything seems to work fine, but I wanted to make sure it was working correctly:)
thanks,
-marc
Afrow UK
8th December 2004 18:12 UTC
If you want to overwrite InstallDir, you simply change the value of $INSTDIR. $INSTDIR will initially contain the value set with InstallDir until you change the value using StrCpy.
E.g.
Function .onInit
IfFileExists "C:\blah\*.*" 0 +2
StrCpy $INSTDIR "C:\blah"
FunctionEnd
-Stu
MysticHead
8th December 2004 22:07 UTC
I wasn't trying to overwrtie anything. I just noticed that by accident I was using InstallDir AFTER I'd already used StrCpy to set $INSTDIR in my .onInit function. It seemed like the InstallDir line was simply being ignored, and I didn't know if that was by design or by chance.
--------------------
E.g.
Function .onInit
IfFileExists "C:\blah\*.*" 0 +2
StrCpy $INSTDIR "C:\blah"
FunctionEnd
Name "mySwellApp"
InstallDir "$PROGRAMFILES\${APPNAMEANDVERSION}"
InstallDirRegKey HKLM "Software\${APPNAMEANDVERSION}" ""
etc...
-----------
Really I guess I can just remove this InstallDir line, as it seems to be ignored. Originally I thought that it might be better to leave it in as a default, incase the $INSTDIR value wasn't set properly. I did some further testing and it looks like NSIS already takes care of the case where $INSTDIR == "" and just forces you to browse for a folder.
I should have given that a shot before posting originally.
Thanks.
-marc
Anders
9th December 2004 01:51 UTC
Installdir is a compile time instruction
kichik
9th December 2004 19:41 UTC
InstallDir sets the default value. The value of $INSTDIR is set as follows:
- Value from command line (/D=)
- If $INSTDIR is invalid, value from InstallDirRegKey
- If $INSTDIR is invalid, value from InstallDir
After all these, your script starts to execute, including .onInit. It is free to change $INSTDIR.
MysticHead
10th December 2004 16:50 UTC
I think I got it
OK, thanks. I think I've got it.
InstallDir is set at compile time (along with InstallDirRegKey) and they will contain the default values of $INSTDIR.
Once the script is actually run .onInit (or other functions) can freely replace that default value, giving $INSTDIR a new (current) value, basically at run time.
So is it correct to say that InstallDir sort of breaks out from the idea that each instruction is read/acted on sequentially? Or is it that it's still read in sequence, but portions of the script are read when compiling and other portions are read when running?
I'm sorry if I'm making this overly complicated. I really do think I understand the answer to my original question, I'm just trying to make sure I've got it straight...not _trying_ to just beat this horse into the ground.
thanks again,
-marc
kichik
10th December 2004 17:50 UTC
InstallDir is performed sequentially, but doesn't belong to the same context as the code in .onInit. It's an installer attribute. If your script has two InstallDir lines, only the last one will count.