Archive: InstallDirRegKey bug?


InstallDirRegKey bug?
I'm trying to get NSIS 2.0b3 to save and recall the directory where my program was installed. I'm using the following line:

InstallDirRegKey HKLM SOFTWARE\FLMM "Install_Dir"

But for some reason, it doesn't work at all! In previous installers I've made it has worked, though that was when I was using v1.98.

Works for me with the NSIS package installer. Are you sure the key is really there? Are you sure the string inside it is valid? Are you sure you are not overriding $INSTDIR somewhere?


Hey there IGx89,

I have experienced the same thing. I don't know whether this is a bug or this is how it's supposed to work now, but I got around it by manually setting the $OUTDIR var like so:

SetOutPath"$INSTDIR"

It seems as if somethng like this:
InstallDirRegKeyHKLMSOFTWAREFLMM"Install_Dir"

will initialize $INSTDIR (of course you may be using .onVerifyInstDir, etc. too)

But it seems to me as if those things (InstallDirRegKey, .onVerifyInstDir) set the $INSTDIR variable but not $OUTDIR which gets used by the File command.

So I just set $OUTDIR manually now, at some point when I'm sure that the $INSTDIR variable is valid.

Makes sense in a funny sorta way. ;) At least I hope it does.

edit: kichik is too fast. :o
kichik, I'll sit down and see for sure whether or not I need to set the $OUTDIR before I can start using File

edit again: I'm sorry. After re-reading IGx89's post, I think I may have understood his problem...

Salaam/Peace.

I'm sure the key isn't there, because that isn't working :)
String inside it? You mean "Install_Dir"?

I'm also already calling "SetOutPath $INSTDIR" in my main section.

Here's my complete header code:

Name "Freelancer Mod Manager"
Caption "Freelancer Mod Manager"
OutFile FLMMInstaller.exe
InstallDir `$PROGRAMFILES\Freelancer Mod Manager`
InstallDirRegKey HKLM SOFTWARE\FLMM "Install_Dir"
DirText 'Directory selection'
XPStyle on
AutoCloseWindow false
SubCaption 0 " - Release Notes"
LicenseText "Freelancer Mod Manager release notes:" "Next >"
LicenseData "D:\My Documents\Visual Studio Projects\FLInstaller\Release\Readme.txt"
ShowInstDetails show
SetDateSave on
InstProgressFlags smooth


psyke, you always have to set $OUTDIR, with or without SetOutPath (that only adds creation of the directory and a nice output to the user) before File unless you specify a full output path using /oname=.

IGx89, what exactly do you mean by isn't working?


kichik: thanks for the clarification. :)
while you were writing that post I looked through the NSIS examples and saw that they all do the 'SetOutPath $INSTDIR' thing - silly me. ;)


I mean that after a successful installation, the key "FLMM" doesn't exist under "HKLM\Software", thus signifying it didn't work. No matter how many times I refresh or reload regedit, it still doesn't show up. But, I noticed another key under HKLM\Software that a previous installer I made had made, that had Install_Dir in it! So, for some reason my old script works (I tested it with both b0 and b3; it worked both times) but the new one I've made doesn't. :(


It's not automatically created, you have to create it yourself :)
Otherwise it can override important information such as the uninstaller path for example which can be used as the source for InstallDirRegKey. It's not a bug, it's a feature :p


DOH! I've been away from NSIS scripting too long; thanks :)

Btw, would anyone be interested in a NSIS script I made that retrieves component information from a text file on a web server? It's an auto-installer I made for Wulfram II (http://www.wulfram.com) that checks for new versions of components and downloads and installs them automatically. I haven't touched the script for a few months, so I figure that I might as well share it if anyone's interested :).


You can create a page at the Archive where everybody can find it - in the Real World Installers section. I'm sure anybody looking for a good example will find it useful.