3
votes

Does anyone have a basic NSIS script example that is "installer based on zip"? Or could tell me the command? I know NSIS has that tool built in, but I want to edit a script based on that. NSIS only outputs an .exe of the installer based on zip. I would like to start from script code.

Thanks.

3

3 Answers

2
votes

The zip2exe tool generates a simple script that it passes to makensis, most of the code is in files it includes:

!define ZIP2EXE_COMPRESSOR_ZLIB
!define ZIP2EXE_INSTALLDIR "c:\foo"

!include "${NSISDIR}\Contrib\zip2exe\Base.nsh" ; You could edit this if you wanted to keep using zip2exe
!include "${NSISDIR}\Contrib\zip2exe\Classic.nsh"

!insertmacro SECTION_BEGIN
File "file1fromzip.txt"
File "file2fromzip.exe"
!insertmacro SECTION_END
2
votes

you can use the following script to extract the zip files in the destination location and before you compile this script you need to download the ZipDLL.dll place it in your NSIS installation folder.

OutFile "Zip.exe"
section
ZipDLL::extractall "C:\Users\raj\Desktop\envConfig.zip" "C:\Program Files (x86)\Zip"

sectionend
0
votes

To build on Anders answer, a few additional things should be done in the latest version. In particular ZIP2EXE_NAME and ZIP2EXE_OUTFILE should be set:

!define ZIP2EXE_COMPRESSOR_ZLIB
!define ZIP2EXE_INSTALLDIR "c:\foo"
!define ZIP2EXE_NAME "My Application"
!define ZIP2EXE_OUTFILE "MyInstaller.exe"

!include "${NSISDIR}\Contrib\zip2exe\Base.nsh"
!include "${NSISDIR}\Contrib\zip2exe\Classic.nsh"

!insertmacro SECTION_BEGIN
File "file1fromzip.txt"
File "file2fromzip.exe"
!insertmacro SECTION_END

Classic.nsh can be replaced with Modern.nsh for the "Modern" UI.

Also note that either the files need to be enumerated in the "File" section, or if you have your files in a folder, you can include the entire contents:

File /r MyFolder\*.*

This will NOT create "MyFolder" inside the install target directory.