5

I'm trying to generalize a setup file by externally passing the version number. I want to be able to do this:

makensis myscript.nsi parameter=value

and then read the parameter within the script, so that using the same script I can generate differently versioned executables. I found this & this, but they seem to be for passing commandline parameters to the generated setup.exe. Is this possible, and how?

7
  • Check out this answer stackoverflow.com/a/2790515/150166 Commented Nov 30, 2011 at 12:07
  • 1
    The linked answer does what you want. I'm not going to vote to close this question though since the title and goal of the question are very different from your.
    – David Hall
    Commented Nov 30, 2011 at 12:16
  • @DavidHall: How is it different? The installer name is an attribute you can only set at compile time! The goal is pretty much the same...
    – Anders
    Commented Nov 30, 2011 at 17:19
  • possible duplicate of NSIS Installer Name
    – Anders
    Commented Nov 30, 2011 at 17:19
  • @Anders I'm not sure that someone searching for how to set compile time parameters in NSIS would find the other question - it doesn't mention any terms like "commandline". They are in the answer of course. I considered asking on meta actually for opinions on what to do since this question strikes me as better (or at least more widely useful than the other) yet it will be the one closed.
    – David Hall
    Commented Nov 30, 2011 at 17:42

1 Answer 1

8

You can add symbols to the globally defined list from the command line using the /D switch:

makensis /DMyVersion="1.0.1" install.nsi

Then you can use them using the ${} syntax:

!ifdef MyVersion
    StrCpy $Version "${MyInstallerName}"
!else
    StrCpy $Version "1.0.0"
!endif

Also of possible interest is the GetVersion plugin discussed in this SO question: NSIS - put EXE version into name of installer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.