Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

As you can see, only two elements are needed to create an installer: the name of the installer and a Section. The installer will do nothing except show you that it’s finished.

 

It helps to notice that even though we did explicitly request any pages to display to the end user, NSIS displayed a progress window anyway. There are a variety of ways to make a silent installer—an installer with no user interface. This document does not discuss how this is accomplished, but you can consult the references in the beginning of this document for instructions on doing this yourself.

 

Let’s modify our bare minimum installer to perform some minor installation procedures.

 

Simple Install

...

In this next example, we add three new commands, seen below in red. 

Code Block
# Name the installer
OutFile "MyInstaller.exe"

# Define the directory to install to using one of the predefined constants
InstallDir $DESKTOP

# Every NSIS script has at least one section.
Section

   # Define the output path for this file
   SetOutPath $INSTDIR

   # Define what to install and place it in the output path
   File "c:\test.txt"

SectionEnd

 

The first instruction, InstallDir, is an installer attribute, so it appears outside of the section. It is used to initialize the built-in INSTDIR variable. It’s possible, later, to modify the INSTDIR variable directly at runtime from within a section or function.

 

The SetOutPath instruction sets the target install directory at runtime. This command is ignored during compilation.

 

The File command is executed in both compile time and runtime. At compile time, this instruction identifies the file to be packaged into the installer. At runtime, it copies the file into the current install directory. 

The result is an installer that executes faster than the eye can see, since we're only installing a single, very small file. The difference now is that the progress bar is full, indicating all files were installed.

...