To add a license page to my installer using NSIS script - nsis

I added this command in NSIS script to add license page
; License page
!insertmacro MUI_PAGE_LICENSE
but i getting this error
!insertmacro: macro "MUI_PAGE_LICENSE" requires 1 parameter(s), passed 0!
help me step step by process to add a license page to my installer thanks

You need to specify the actual license to be displayed (text or rich text format)
!insertmacro MUI_PAGE_LICENSE "path\to\myLicense.txt"

Related

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.

When I run the instaler in German locale installer UI is showing in German but the application UI is not showing in German using NSIS

When I run the installer in the German locale, installer UI is showing in German but the application UI is not showing in German. Instead it is showing in English.
For the Installer UI to work as per the locale I have created separate .nsh files (!include "CustomEnglish.nsh",!include "CustomGerman.nsh",!include "CustomItalian.nsh") and included those in my .nsi file. So it is working as expected.
For the application UI to work as per the locale, I am using the below check based on the Language and placing the files (created separate resouce dlls for each language) in the Installed directory.
Is it the correct way to place the dlls or files based on the locale in the Installed directory?
And also I am not using the statement !insertmacro MUI_LANGUAGE "English" in this .nsi file. Because this statement I am giving in the !include "CustomEnglish.nsh" (I have also attached CustomEnglish.nsh for the reference)
Please help me why the application UI is not showing in German?
Below is the complete code:
!include "MUI2.nsh"
!include x64.nsh
!include WinVer.nsh
Name "Millinnium 4.0"
RequestExecutionLevel admin
;RequestExecutionLevel user
; Below is the include file to check the conditions (If and else)
!include LogicLib.nsh
;Customizing the Welcome Text
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_INSTFILES
${EndIf}
SectionEnd
;--------------------------------
Section "Uninstall"
SectionEnd
CustomEnglish.nsh
!insertmacro MUI_LANGUAGE "English"
!define ApplicationName "Millinnium"
LangString welcometitle ${LANG_ENGLISH} "Welcome to the ${ApplicationName} Setup Wizard"
LangString welcometext ${LANG_ENGLISH} "The Setup Wizard will install ${ApplicationName} on$\r$\nyour computer. Click Next to continue or Cancel to exit the$\r$\nSetup Wizard."
LangString licensetitle ${LANG_ENGLISH} "End-User License Agreement"
LangString licensesubtitle ${LANG_ENGLISH} "Please read the following license agreement carefully"
LangString licensecheckboxtext ${LANG_ENGLISH} "I &agree to terms in the License Agreement"
LangString mydirtoptext ${LANG_ENGLISH} "Install ${ApplicationName} to:"
LangString mydirtitle ${LANG_ENGLISH} "Destination Folder"
LangString mydirsubtitle ${LANG_ENGLISH} "Click Next to install to the default folder or click Browse to choose another"
I found the root cause of not displaying the UI in other language (for eg, French). It is because i didn't include the language specific folder (for eg, "fr" that has resources.dll) in "INSTDIR".
To include that I have written the below lines of code and it is working now:
SetOutPath $INSTDIR\fr
File /a /r "C:\Code\EMR\bin\x86\Release\fr\"

Custom texts for uninstaller

So I made patch installer for certain game. It works nicely, dumb design decisions of NSIS notwithstanding. I use NSIS 3.03 with MUI2.
Due to nature of patch (it is not separate application, just patch applied on already existing program) I had to use pretty much all custom texts for installer (like MUI_WELCOMEPAGE_TITLE, MUI_WELCOMEPAGE_TEXT etc). Grammar of my native language didn't helped.
But then I foolishly wanted to include uninstaller. While it works, it seems like there are almost no custom texts for it. Only ones that work are MUI_UNCONFIRMPAGE_TEXT_TOP and MUI_UNCONFIRMPAGE_TEXT_LOCATION. Other default texts for uninstallator look like crap due to aforementioned issues (patch instead of real app, grammar).
For example, on welcome page of uninstaller there is text similar to "Before starting the uninstallation, make sure [NAME OF PATCH TO GAME] is not running.". It should be something like "Before starting the uninstallation, make sure [NAME OF GAME, NOT NAME OF PATCH] is not running.". No, there is no MUI_UNWELCOMEPAGE_TEXT or anything like that.
How to change other texts in uninstaller? This kind of oversight is silly for 10 year old installer creator on its third major version. WTF?
From the documentation:
Page settings apply to a single page and should be set before inserting a page macro. The same settings can be used for installer and uninstaller pages. You have to repeat the setting if you want it to apply to multiple pages.
!include MUI2.nsh
!define MUI_WELCOMEPAGE_TEXT "Installer blah blah"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_WELCOMEPAGE_TEXT "Uninstaller blah blah"
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE "English"
Section
SetOutPath "$InstDir"
WriteUninstaller "$InstDir\Un.exe"
ExecShell "" "$InstDir\Un.exe"
SectionEnd
Section Uninstall
Delete "$InstDir\Un.exe"
RMDir "$InstDir"
SectionEnd

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.

Resources