How can I change the dir of the header image? - nsis

I have seen in all scripts when I have to change the image header that uses the ${NSISDIR} like this:
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_HEADERIMAGE_BITMAP ${NSISDIR}\Contrib\Graphics\Header\nsis-r.bmp
But I need to put the image in other folder to not depending of NSIS dir.
Does anyone know how to do this?
I can not depend of /home/username too.
I want that because the wizard can be compiled in any linux PC.

You can try a relative path...
Edit:
Use a relative path when the .bmp is in the same folder tree as your .nsi:
!define MUI_HEADERIMAGE_BITMAP .\mygfx\header.bmp
If you want to use one of the other NSIS images you should just use the NSISDIR define, the POSIX compiler will convert the path:
!define MUI_HEADERIMAGE_BITMAP ${NSISDIR}\Contrib\Graphics\Header\nsis-r.bmp

You just use
Contrib\Graphics\Header\nsis-r.bmp
And folder Contrib is local to script place(folder)

Related

How can I create a single NSIS script which will generate different installers based on an input parameter?

I have an application which has development, testing and live versions. I have a command procedure which currently creates 3 different versions of the installer, which can be installed on 3 separate computers.
What I would like to do would be to have one NSIS script which I pass in a parameter to, which will create one of the versions of the installer changing the name of the product and the installation folder. This will allow me to install all 3 versions on the same computer.
What I have tried so far is;
Function .onInit
Var /GLOBAL INSTALL_TYPE
${GetOptions} $CMDLINE "/t" $INSTALL_TYPE
${if} $INSTALL_TYPE == ""
StrCpy $INSTALL_TYPE "Live"
ReadEnvStr $R0 SYSTEMDRIVE
StrCpy $INSTDIR "$LOCALAPPDATA\Programs\MyComp\MyApp$INSTALL_TYPE\"
FunctionEnd
!define MUI_PRODUCT "FCDS-RECAP$INSTALL_TYPE"
OutFile "MyApp-$INSTALL_TYPEinstaller.exe"
One of the main errors I get has to do with MUI_PRODUCT and look similar to;
warning 6000: unknown variable/constant "INSTALL_TYPE.lnk" detected, ignoring (FullDeploymentUser.nsi:121)
warning 6000: unknown variable/constant "INSTALL_TYPE" detected, ignoring (FullDeploymentUser.nsi:124)
Two types of comments would be useful;
This is what you are doing wrong...
This is what you should be doing...
As always any help is appreciated.
MUI_PRODUCT is technically not an official NSIS define, some guy just invented it and used it in a guide.
All instructions starting with ! are preprocessor instructions, those and OutFile and File cannot be controlled by ${GetOptions} because they happen at compile time on your developer machine.
I don't really recommend this 3 in 1 installer solution, it is a bit complicated. It is much better to just create 3 different installers:
!ifndef APPTYPE
!error "APPTYPE not defined"
!endif
Name "MyApp ${APPTYPE}"
OutFile "MyApp ${APPTYPE} setup.exe"
InstallDir "$ProgramFiles\MyApp ${APPTYPE}"
Page Directory
Page InstFiles
Section
SetOutPath $InstDir
File /r "c:\myfiles\MyApp\${APPTYPE}\*"
SectionEnd
and then just generate them with makensis -DAPPTYPE=Beta myapp.nsi etc.
If you really want this 3 in 1 style then you need to use the macros in Sections.nsh to manipulate the sections so that only one of them is visible and active. You also need to mark the install somehow (.ini file?) so that your uninstaller also knows which install type it is uninstalling.

Need NSIS example script with all necessary files for script to run

I am very new to NSIS, and i was wondering if there is a way to change the splash screen with modern UI, on the first and last pages:
Installer Closing Page
Installer Opening Page
!define MUI_WELCOMEFINISHPAGE_BITMAP "c:\myfiles\wizard.bmp"
!include MUI2.nsh
...
This is of course documented in the Readme.

License related issue in NSIS Script

I want to add a license page in my installer actually i wrote a script like this
; License page
!insertmacro MUI_PAGE_LICENSE "$INSTDIR\LICENSE.rtf"
Section ""
SetOutPath $INSTDIR
; Put file there
File "LICENSE.rtf"
But while compiling i am getting this issue.
LicenseData: open failed "$INSTDIR\LICENSE.rtf"
please let me know where to place the License.rtf file for access
For compiling you should give path of licence file where it is actually present when you are compiling.

NSIS Installer based on zip?

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.
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
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
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.

Multiple paths in NSIS. Code doesnt get executed

I need to ask user for several paths before installation, but i cannot get it done in NSIS. Seems like my code doesnt get referenced in MUI:
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico""
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
!define MUI_CUSTOMPAGECOMMANDS
!define MUI_DIRECTORYPAGE
!define MUI_CUSTOMFUNCTION_COMPONENTS_LEAVE ComponentPost
!define MUI_CUSTOMFUNCTION_DIRECTORY_SHOW DirectoryShow
!define MUI_CUSTOMFUNCTION_DIRECTORY_LEAVE DirectoryLeave
And at compilation I get
install function "ComponentPost" not referenced - zeroing code (0-2) out
install function "DirectoryShow" not referenced - zeroing code (2-49) out
install function "DirectoryLeave" not referenced - zeroing code (49-61) out
Obviously, it the code of these three functions doesnt get executed
First time I see !define MUI_CUSTOMPAGECOMMANDS and some others. There is no reference for them in NSIS or manual. What are them?
If you want to add page Directory into your installer use macro named MUI_PAGE_DIRECTORY (and not MUI_DIRECTORYPAGE)
To add PRE/SHOW/LEAVE functions for this page use
MUI_PAGE_CUSTOMFUNCTION_PRE function
MUI_PAGE_CUSTOMFUNCTION_SHOW function
MUI_PAGE_CUSTOMFUNCTION_LEAVE function
These defines should be set before inserting a page macro.
I think the easiest way for you is to modify an existing example (can be found in NSIS\Examples directory), your script does not make a sense at all.

Resources