Opening a pdf/Wordpad file at Installation finish - nsis

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

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"

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

Run application after install(silent installer)

I want to run my application immediately after install and I understand the code to do it is as follows:
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
!insertmacro MUI_PAGE_FINISH
Section
CreateShortcut "$DESKTOP\HelloWorldShortcut.lnk" "$INSTDIR\Hello World.exe" "dev03 3"
SectionEnd
Function LaunchLink
ExecShell "" "$DESKTOP\HelloWorldShortcut.lnk"
FunctionEnd
The problem is my installer is a silent installer but the above code adds a page to it.
Is there a way to use a silent installer to also run the application immediately after install?
A silent installer can just run the app as the final step in the last section. Whether or not it is a good idea for a silent installer to start the application is something you should think about, personally I would say no...
Section
SetOutPath $InstDir
File "MyApp.exe"
...
IfSilent "" +2 ; If the installer is always silent then you don't need this check
ExecShell "" "$InstDir\MyApp.exe"
SectionEnd

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