Skip to content
⌘ NSIS Forum Archive

How to determine makensis version?

5 posts

Marshallx7#

How to determine makensis version?

Before I execute makensis.exe, I need to know what version of NSIS I am about to use.
How can I programatically determine the installed version of NSIS, without first building an installer? (I need to be able to do this on both windows and linux)

My first thought was to just look at the VI keys of makensis.exe but it doesn't have any...
I tried searching in files for the version number but turned up nothing!

I don't mind where I get the version from as long as it is consistent for v2.51+ and v3+
And I really don't want to build a dummy installer and run it just to get the version number.

The main thing I need is just to be able to tell v2 from v3, so I could settle for a reliable way of determining that.

Any assistance is much appreciated!
Anders#
MakeNSISW runs makensis with the version switch and parses the output but if all you want to do is detect v3+ then you have some more options if you don't mind hacks:

Makensis.exe v3 is Unicode and imports the "CreateProcessW" function (Windows only of course).

"NSIS\bin\makensis.exe" will contain the string NSIS_VERSION in UTF16 or UTF32 in v3 and in ASCII in v2.

"NSIS\Stubs\*unicode*" will only exist in v3+

You can also run makensis with the -X switch and execute !appendfile "whatever.txt" "${NSIS_VERSION}" without having a dummy .nsi.

Why do you need to tell the difference? v3 should behave like v2 by default...
Marshallx7#
That's really helpful, thanks Anders. I'm sure one of those methods will suffice.

I am making a quite substantial preprocessor and the specific use case atm is whether or not Unicode is supported.
In the long run I only plan to support NSIS3 with Unicode always on anyway but some plugins haven't quite caught up yet.

I also intend to provide custom pre-processing based on NSIS version, perhaps other built in compile-time values too.
Anders#
In that case, you should also look at the makensis hdrinfo switch (or whatever it is called), it will print out some of the NSIS_* defines...
Marshallx7#
This was most helpful.
I'm using the -X"!appendfile... trick and /hdrinfo also made me aware of some relevant defines.
This is great, as using !verbose 0 means it doesn't even warn about not having OutFile set.

Many thanks.