Hello, listers!
I am at a loss.
I have two almost identical scripts. In both of them I initialize $instdir at compile time. Then, in the .onInit I have:
IfFileExists "$INSTDIR\myfiles*.*" Jump_if_Good Jump_If_Bad
but $INSTDIR does not initialize and installer behaves as though the files are not found. If I substitute $INSTDIR with an actual directory, then everything works fine.
The interesting thing is that the function which initializes the $INSTDIR at compile time is exactly the same in both scripts.
Do you have any idea about the possible causes of this misbehavior?
Thanks,
Victor
$INSTDIR does not initialize in .onInit function at runtime
16 posts
It would be helpful to see the function that initializes $INSTDIR
attach script, dude 🙂
$INSTDIR is set before .onInit if InstallDir and/or InstallDirRegKey are specified.
Hello, guys!
OK, here goes the script.
Regards,
Vic
OK, here goes the script.
Regards,
Vic
I find you error:
The above line is wrong, is should:
InstallDir "$INSTDIR"
InstallDir "$PROGRAMFILES\${MUI_PRODUCT}" ;or another you want
Well, it works in another script. Plus I want my $INSTDIR to be generated at runtime depending on the conclutions drawn from reading appropriate registry keys.
Regards,
Victor
Regards,
Victor
$INSTDIR contains the installation directory "variable"
from one of these three:
1. From the registry using the InstallDirRegKey.
2. When you use the InstallDir.
3. When the user use the Browse button the change the Installation path.
from one of these three:
1. From the registry using the InstallDirRegKey.
2. When you use the InstallDir.
3. When the user use the Browse button the change the Installation path.
Here's how it works:
InstallDir "$PROGRAMFILES\Jeff"
$INSTDIR="C:\Program Files\Jeff"
InstallDir "$PROGRAMFILES\Jeff"
$INSTDIR="C:\Program Files\Jeff"
Thank you everybody. I can't believe how unattentive I was. There was a typing error in the line
InstallDirRegKey HKLM "Software\${MUI_PRODUCT}" "Install_Dir"
I accidentally omitted a quote.
So the following reads correct and works fine.
InstallDir "$INSTDIR"
InstallDirRegKey HKLM "Software\${MUI_PRODUCT}" "Install_Dir"
Now my $INSTDIR is defined at run time.
Regards,
Vic
InstallDirRegKey HKLM "Software\${MUI_PRODUCT}" "Install_Dir"
I accidentally omitted a quote.
So the following reads correct and works fine.
InstallDir "$INSTDIR"
InstallDirRegKey HKLM "Software\${MUI_PRODUCT}" "Install_Dir"
Now my $INSTDIR is defined at run time.
Regards,
Vic
Your code is still wrong. The InstallDir sets $INSTDIR if InstallDirRegKey fails. You set something to itself when it's empty. It only works for you because the registry key is there, once it's gone you'll get an empty one instead. If you do want an empty $INSTDIR if the registry key is not there then you just don't need InstallDir.
I have this and it works:
This isn´t right: InstallDir "$INSTDIR"
InstallDirRegKey HKLM "Software\${MUI_PRODUCT}" "Install_Dir"
InstallDir "C:\path"
OK, but then I don't understand something. How would I change $INSTDIR at run time? A very basic scenario: my installation directory will change depending on the version of another application installed. If I declare some path for InstallDir, then I have to stick with it. That's not what I want.
My current scenario works because if there is no InstallRegKey for my application, then I assume it was never installed on this computer, otherwise, I check for existence of certain files.
Regards,
Vic
My current scenario works because if there is no InstallRegKey for my application, then I assume it was never installed on this computer, otherwise, I check for existence of certain files.
Regards,
Vic
In the Nsis Manual check for "SetOutPath" instruction.
Hello,
Kichik, you were right, I grant. I took out the line
InstallDir "$INSTDIR"
and it still works the same. I think I understand my mistake now.
Thanks everybody.
Regards,
Vic
Kichik, you were right, I grant. I took out the line
InstallDir "$INSTDIR"
and it still works the same. I think I understand my mistake now.
Thanks everybody.
Regards,
Vic
Just to make sure everybody understand, this is how it works:
You can change $INSTDIR wherever you want in the script with worrying about InstallDir and InstallDirRegKey. Those just give the initial values.
- Installer starts
- The value specified using InstallDir is copied to $INSTDIR
- The value specified using InstallDirRegKey (if found) is copied to $INSTDIR
- .onInit is called, and later everything else
You can change $INSTDIR wherever you want in the script with worrying about InstallDir and InstallDirRegKey. Those just give the initial values.