Archive: NSIS with main() function and no others or sections or pages?


NSIS with main() function and no others or sections or pages?
Is there a stripped down version of NSIS that doesn't require sections, pages, or other built in functions.

In other words, a generalized scripting system supporting all the NSIS great functions and plugins, but doesn't require the install domain specific sections, pages, or install specific callback functions.

The only required function would be main()

That'd be hot...


no, but then you can make a very minimal installer of the type you describe with just this:


OutFile "Setup.exe"

Section ""
SectionEnd

Function .onInit
; your code here
Abort
FunctionEnd


Put the code you want in .onInit. The 'Abort' at the end will make the installer exit immediately, without any UI being loaded, etc. At the top you might still want to specify a compressor, but for the sake of minimalism.. the above is it.

Or even shorter,

OutFile file.exe
SilentInstall silent

Section
...
SectionEnd

Stu


Afrow's solution also generates a smaller executable.


fancy :)


Silent installers get stripped of their resources and some language strings are also not included so the overhead is smaller.


And if you want it even smaller, you can use UPX to pack the overhead and then you can remove the icon with Resource Hacker, both by using !packhdr. You can't use !packhdr more than once so you need to use batch scripts.

Just to share with everyone, the batches I use in every installer I make:

NSIS\packhdr\upx.bat


cd /d %~dp0

upx %1

NSIS\packhdr\noicon.bat

cd /d %~dp0

ResHacker -delete %1, %1, icongroup,103,
del ResHacker.log

NSIS\packhdr\noicon+upx.bat

cd /d %~dp0

ResHacker -delete %1, %1, icongroup,103,
del ResHacker.log

upx %1


Example NSIS code to compress overhead and remove icon:
!packhdr $%TEMP%\exehead.tmp `"${NSISDIR}\packhdr\noicon+upx.bat" "$%TEMP%\exehead.tmp"`

You need to extract Resource Hacker and UPX to NSIS\packhdr as well of course.

http://angusj.com/resourcehacker/
http://upx.sourceforge.net/

Stu