How to keep NSIS install window open? - nsis

When I press "Install" there is a small window showing the files that are being copied and other operations such as registering dlls, etc..
I would like to keep that window open when it done.

!define MUI_FINISHPAGE_NOAUTOCLOSE
!include MUI2.nsh
...
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

Related

Nullsoft Installer NSIS not showing an image on the welcome page. Not even the default one

I'm trying to write an NSIS script using MUI2 and for some reason it refuses to show an image on the welcome page. I have tried using MUI_WELCOMEFINISHPAGE_BITMAP as instructed in the NSIS wiki and manual. I have used ${NSISDIR} to reference the included bitmaps. I have tried using a full path to the included bitmaps. I have tried using a path to a bitmap in my installation files directory.
No matter what I do, I end up with a Welcome page that has a title and text, but no image. The build process gives no warnings or errors concerning the welcome bitmap. The installer installs everything correctly. There's just no image on the welcome page and I cannot figure out why.
This is my first attempt at using NSIS, so there's probably something I'm missing. The section of my .nsi file with the page definitions is below. Any help would be appreciated.
!include MUI2.nsh
# Install Warcraft II BattleNet Edition and dependencies.
Name "Warcraft II Windows 10 Setup"
Outfile "Warcraft Win10 Setup.exe"
InstallDir "C:\ISO"
# !define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp"
!define MUI_WELCOMEPAGE_TITLE "Warcraft II for Windows 10"
!define MUI_WELCOMEPAGE_TEXT "Ready to work!$\r$\n$\r$\nWith just a few simple steps, our peons will have you ready to play Warcraft II on Windows 10."
!insertmacro MUI_PAGE_WELCOME
!define MUI_DIRECTORYPAGE_TEXT_TOP "Choose a location to store the Warcraft II CD-ROM (ISO) image."
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "ISO Image Folder"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_TEXT "Work complete!"
!insertmacro MUI_PAGE_FINISH
Also make sure that the bmp is really 24 bit. Otherwise it will not be rendered.
I found the solution and am posting for anyone else experiencing the same problem.
In short, the answer is: !insertmacro MUI_LANGUAGE "English"
Apparently, one must specify a language for a bitmap to show up. Makes total sense, huh? And yes, Virginia, that was sarcasm.
I figured this out by taking the example from the website below and commenting lines out until I reproduced my problem with the lack of a bitmap image appearing on the welcome page.
https://nsis.sourceforge.io/Examples/Modern%20UI/WelcomeFinish.nsi
The working code looks like this:
!include MUI2.nsh
# Install Warcraft II BattleNet Edition and dependencies.
Name "Warcraft II Windows 10 Setup"
Outfile "Warcraft Win10 Setup.exe"
InstallDir "C:\ISO"
!define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\orange.bmp"
!define MUI_WELCOMEPAGE_TITLE "Warcraft II for Windows 10"
!define MUI_WELCOMEPAGE_TEXT "Ready to work!$\r$\n$\r$\nWith just a few simple steps, our peons will have you ready to play Warcraft II on Windows 10."
!insertmacro MUI_PAGE_WELCOME
!define MUI_DIRECTORYPAGE_TEXT_TOP "Choose a location to store the Warcraft II CD-ROM (ISO) image."
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "ISO Image Folder"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_TEXT "Work complete!"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"

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

How to show the Systray Icon and also the corresponding executable in the taskmanager by default when we run the installer using NSIS?

My requirement is: When i installed a software using NSIS, once the installation is successfully completed it should show a notification icon (systray icon).
I am able to create the installer with the required dlls, executables and other files. But it is not showing the systray icon automatically.
Use ExecShell, Exec or ExecWait to start a new process:
Section
SetOutPath $INSTDIR
File "something\Display.exe"
ExecShell "" "$INSTDIR\Display.exe"
SectionEnd
If you are using the Modern UI then you can put a run checkbox on the finish page instead if you want to give the user the option of not running the app:
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\Display.exe"
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
Section
SetOutPath $INSTDIR
File "something\Display.exe"
SectionEnd

Opening a pdf/Wordpad file at Installation finish

I am using HM NIS Edit 2.03. For my setup installation, I need to open a help file at the end of the installation. The file may be a pdf, notepad or a word page file. I tried !define MUI_FINISHPAGE_RUN but it does not work.
MUI_FINISHPAGE_RUN can only start real applications, to start other things you can use MUI_FINISHPAGE_SHOWREADME. If you are already using MUI_FINISHPAGE_SHOWREADME for something else you can use a custom run function:
Function MyFinishRun
ExecShell "" "$instdir\readme.doc"
FunctionEnd
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION MyFinishRun
!insertmacro MUI_PAGE_FINISH

Resources