Archive: Name, OutFile, InstallDir


Name, OutFile, InstallDir
Hey! I am new to this and have mananged to find answers to most questions that have poped up. But with this one I could use some help.

I need to be able to change the name, outfile and installdir among other things depending on the users nationality. Right now the installer is a modified version of Modern UIs MultiLanguage.nsi.

So I have the following code:

var PublisherName
var ProductGroup
var ProductName

;Name and file
Name $ProductName

;Default installation folder
InstallDir "$PROGRAMFILES\$(^PublisherName)\$(^ProductGroup)\$(^ProductName)"

Function .onInit

StrCpy $PublisherName "a"
StrCpy $ProductGroup "b"
StrCpy $ProductName "c"

When the installer is run the default path is:
C:\Programs\\\

Guessing this means that the InstallDir code is run before the .onInit and not update after the .onInit has been run. But there must be some way to make this work...

Help would be greatly appriciated!


Function .onInit
...
StrCpy $instdir "c:\some fancy path\$myvar\hello"
FunctionEnd


What you're looking for is !define and ${const}.

!define PUBLISHER_NAME a
!define PRODUCT_GROUP b

InstallDir $PROGRAMFILES\${PUBLISHER_NAME}\${PRODUCT_GROUP}

Wow, those are some fast replies, impressive and much appreciated. Bit confused. Can NSIS !define be changed at run-time? Else I don't understand how that would work...


NSIS defines can't be changed at runtime, but if you want to change OutFile as well, you have to use !defines as that can never change on runtime.