Archive: Write true install path to .INI string


Write true install path to .INI string
I've searched the fourms here for about two days, hoping someone else would have had my problem, but I guess i'm not using the correct search terms.

Here's my problem. I'm using the Modern UI for my installer, and i've set the Install Directory to "$DOCUMENTS\Test Run". Since this is a basic setup, easily deleted when they are done with the files, I don't want to create any registry keys since there is no uninstaller. I've also got the script set up to create an .ini file in the Windows Directory, so when I release an update to the first set, the following sets can simply look to the .ini file and read the install path if it's different than what I set as default.

The problem.

in my script I have this...

# Installer attributes
OutFile E:\Temp\Releasing\Test.exe
InstallDir "$DOCUMENTS\Test Run"
Which works wonderfully. Then, at the end I have this...

# Installer functions
Function .onInit
WriteINIStr "$WINDIR\Test.ini" "Install Path" "Install_Dir" "$INSTDIR"
InitPluginsDir
FunctionEnd
Now, when the installer gets to the install directory page, I have the option for the user to choose another path to install the files to. If they change the path from the default "$DOCUMENTS\Test Run" one, the .ini file still only records the default install directory.

I hope i'm explaining myself here, if the user chooses some random install path like "c:\gibberish\another folder\more gibberish" the .ini file will still record "c:\My Documents\Test Run"

How do I get the .ini file to record the actual install path? Am I missing some part of the readme included with NSIS?

ThanQ in advance for your help.

If you write the install path before the user has changed it, what do you expect? lol
.onInit is executed when the installer is executed, not after the directory page.
You need to write it after the directory page, e.g. in the Leave function.

-Stu


lol, yeah, how would I expect the installer to know the new path that the user has changed, even tho it seems to install all the files to the new path and the .ini file doesnt seem to be generated until the files are all installed. Silly me.

Nonetheless, I shall check out this leave function you speak of. Thank you for your reply.