Archive: Setting InstallDir from reg key but manipulating first.


Setting InstallDir from reg key but manipulating first.
Hello Mr DJ. Long time lister, first time caller...

I've only just stared using NSIS and despite reading, re-reading, browsing the FAQ and archives I've got myself in a tizz over this little problem.

I would be ever so greatful is some kind soul could help me out of my quandry.

First up, I'm using 2.0b3 and the Modern User Interface - just so you know.

Problem is as follows. When my user comes to the "Choose Install Location" section, I need to pre-set what that install dir will be.

Now, the actually path I want is in the registry BUT, and this is the catch, I need to manipulate it before its set as InstallDir.

Heres the problem.

My install path can be read from:
HKCU\Software\Company\Product\InstallPath

which returns something like:

C:\Program Files\Product\UserName\Prefs

Now, what I need to do is alter that returned value by removing the "Prefs" part and appending some extra info to it. e.g.

C:\Program Files\Product\UserName\Data\NewStuff

The "Data\NewStuff" will be defined as a variable in the script and the above modified path should be what appears in the Install Location dialog and also be the value of $INSTDIR (or some other suitable var such as $OUTPATH).

Now this has got me foxed because the users who will be using this installer are not *that* bright hence the need to prompt them with the correct path in the directory text box.

To be honest, the NSIS scripting language does confuse me a bit and I cannot figure out how to achieve this so I would be awfully greatful is someone could help me out.

Thanks in advance.

- Jed


Simply edit $INSTDIR in .onInit. Use GetParent (a function in one of the appendixes of the manual) to remove Prefs and then simply use:

StrCpy $INSTDIR $INSTDIR\Data\NewStuff