Archive: Restricting scripts to particular versions of NSIS


Restricting scripts to particular versions of NSIS
  After running NSIS Update tonight I found that I had to change my custom page commands to take into account the new leave-page function parameter. For example:

Page custom Intro " - Introduction"

had to be changed to

Page custom Intro "" " - Introduction"

If I give the modified script to another NSIS user, it will only work if they have also run NSIS Update to update their copy of NSIS.

Is there a way to make my script detect the version of NSIS in use and issue an error message if an old version of NSIS is being used?


There is no easy way to do it but if you really want then you can create a little installer or a program that compares the given input to the output of makensis.exe /version and call that program using !system. If you write it as a small silent installer then you'll need to call Abort or Quit to change the return value of the installer to 1. If the installer finishes without any errors or calls to Abort or Quit it will return 0.


I would suggest making a small program to compile the script for you. If the NSIS version is compatible just define a variable to the script.. IE:

!ifndef NSISOK

;Set the definitions and such that are causing you problems with
;the newer version.
!else
;Place the definitions that you are using here.
!endif
In the program, when calling MakeNSIS.exe just use the /DNSISOK="1" in the command line. This is what I've been using for my script to check if it is the test installer or the actual distributable version. Thank Joost for this suggestion, he's the one that brought it to my attention :)

Thanks for the ideas, I will try something based upon your suggestions.


I'll be cool if Nsis have version numbers within.
So that can we use it with GetDllVersion.


What do you think of an NSIS instruction, like:
ForNSISVersion 2.0b2
If this is specified, this script can only be compiled with that version. Using
ForNSISVersion 2
would make the script compilable by all version 2 NSIS compilers, and
ForNSISVersion 2.0b2+
would make the script only compilable for NSIS 2.0b2 and higher.


Originally posted by Dark Boy
I'll be cool if Nsis have version numbers within.
So that can we use it with GetDllVersion.
It should be checked on compile time, the normal commands won't work.

virtlink, I don't see how that could help with CVS version which are the real problem here. For normal version you can just put a comment that this script only works on version *, but for CVS it's impossible.