In January 2006 NSIS was SourceForge's project of the month.<ref>[https://sourceforge.net/blog/potm-2006-01/ SourceForge.net Project of the Month] in January 2006</ref><ref>{{cite web |url=http://www.opencandy.com/2011/06/09/installer-platform-comparison-making-the-right-choice/ |title=OpenCandy Installer Platform Comparison |access-date=2011-06-27 |url-status=bot: unknown |archive-url=https://web.archive.org/web/20110627230641/http://www.opencandy.com/2011/06/09/installer-platform-comparison-making-the-right-choice/ |archive-date=27 June 2011 }}</ref>
== ScriptExample examplescode ==
=== Hello world! ===
<syntaxhighlight lang="nsis">
!include "MUI.nsh"
!insertmacro MUI_LANGUAGE "English"
Name "Hello world!" # Name of the installer.
OutFile "HelloWorld.exe" # Name of the installer's file.
Function .onInit # Function that will be executed on installer's start up.
MessageBox MB_OK|MB_ICONINFORMATION "Hello world!" # Show a message that says "Hello world!".
Quit # Close the installer because this is a simple "Hello world!" installer.
FunctionEnd
Section # Useless section because this is a simple "Hello world!" installer.
SectionEnd
</syntaxhighlight>
=== Simple installer ===
<syntaxhighlight lang="nsis">
!include "MUI.nsh"
</syntaxhighlight>
==Plugins==
=== Simple installer that adds a shortcut in the start menu and comes with an uninstaller ===
<syntaxhighlight lang="nsis">
# define name of installer
OutFile "InstallMyApp"
# define installation directory
InstallDir $LOCALAPPDATA\Programs\myapp
# For removing Start Menu shortcut in Windows 7
RequestExecutionLevel user
# start default section
Section
# set the installation directory as the destination for the following actions
SetOutPath $INSTDIR
# create the uninstaller
WriteUninstaller "$INSTDIR\uninstall.exe"
# point the new shortcut at the program uninstaller
CreateShortcut "$SMPROGRAMS\My App.lnk" "$INSTDIR\myapp.exe"
CreateShortcut "$SMPROGRAMS\My App Uninstall.lnk" "$INSTDIR\uninstall.exe"
File /r "C:\path\to\where\my\files\are\*"
SectionEnd
# uninstaller section start
Section "uninstall"
# first, delete the uninstaller
Delete "$INSTDIR\uninstall.exe"
# second, remove the link from the start menu
Delete "$SMPROGRAMS\My App.lnk"
Delete "$SMPROGRAMS\My App Uninstall.lnk"
Delete $INSTDIR
# uninstaller section end
SectionEnd
</syntaxhighlight>
==Concepts==
[[File:Nsis1.png|right|thumb|300px|NSIS 1.98]]
===Script===
The NSIS compiler program ''makensis'' compiles scripts like the following example into executable installation programs. Each line in the script contains a single command.
<syntaxhighlight lang="nsis">
# Example script
Name "Example1"
OutFile "jubaowu.exe"
InstallDir "$PROGRAMFILES\Example1"
Page Directory
Page InstFiles
Section
SetOutPath $INSTDIR
File ..\makensis.exe
SectionEnd</syntaxhighlight>
===Modern user interface===
Version 2.0 introduced a new optional streamlined graphical user interface called ''Modern UI'' (MUI). The MUI has a wizard-like interface. It supports a welcome page, finish page, language selection dialog, description area for components, and greater customization options than the old user interface.
<syntaxhighlight lang="nsis">
# Modern UI example script
!include MUI.nsh
Name "Example 2"
OutFile "Example2.exe"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "license.rtf"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "French"
Section "Extract makensis"
SetOutPath $INSTDIR
File ..\makensis.exe
SectionEnd</syntaxhighlight>
Since NSIS version 2.30 (Released on 25 August 2007) there is new version (beta) of this UI accessible: Modern UI 2 (MUI2) which is an enhancement to Modern UI. Unlike the old MUI this version is based on nsDialogs instead of old-fashioned InstallOptions .ini files.
From version 2.34 (Released on 24 December 2007) this MUI2 is ready for mass consumption and it is included in all NSIS packages. Also all examples had been switched to it.
Modern UI 2 documentation.
====Graphical interfaces====
NSIS projects can be configured by simply editing text files (with .nsi extension). However, several third parties provide editing software:
* EclipseNSIS is a module for the [[Eclipse (software)|Eclipse]] platform. It allows NSIS scripts to be edited, compiled and validated.
* HM NIS Edit (freeware) editor with support of custom [[C++]] or [[Delphi (programming language)|Delphi]] plug-ins.
* Venis (freeware) editor
* Visual & Installer is an add-in which integrates NSIS with [[Microsoft Visual Studio]] IDE and allows to create and build NSIS projects right within it.
====Installer interfaces====
Several projects that extend or replace the Modern UI have started in the past few years. Interfaces such as the ExperienceUI and UltraModernUI completely change the style of the installer by skinning it to look like the [[InstallShield]] interface. Other interfaces like installSpiderUI aim for a more minimalistic approach on the visual side of things while maintaining the same level of functionality as the ASD.
===Plugins===
NSIS can be extended with [[Plug-in (computing)|plugins]] that can communicate with the installer. Plugins can be written in any unmanaged programming language capable of building a [[dynamic-link library]] (such as C, C++ or Delphi), and they can be used to perform installation tasks or extend the installer interface. A plugin can be called with a single line of NSIS code.
Several plugins come with the NSIS package that permit the installer to display a splash screen, display a custom page, display an image on the background, download files from a website, perform mathematical operations, patch files and more.
Other plugins are available online, including ZipDLL, and a [[Python (programming language)|Python]] plugin.
==Features==
NSIS supports the following features:<ref name=featuresSF>{{cite web|url=http://nsis.sourceforge.net/Features|title=Features|publisher=NSIS}}</ref>
*[[zlib]], [[bzip2]], and [[LZMA]] compression
*Script-based
*Multilingual
*[[Plug-in (computing)|Plugin]] support
*Script [[preprocessor]]
==Generated installer==
The generated installer is a [[Portable Executable]], with the installation files archived within the installer, a 34 KB overhead for the NSIS installer,<ref name=featuresSF>{{cite web|url=http://nsis.sourceforge.net/Features|title=Features|publisher=NSIS}}</ref> and the installation script compiled into executable code. As the installation script is compiled, the script cannot be obtained from the delivered executable without reverse-engineering the binary.
The archive may be unpacked using [[7-Zip]], the [[Total Commander]] plugin InstallExplorer, or the [[FAR Manager]] plugin InstallExplorer.
The archive contains several folders:
* '''$PLUGINSDIR''' : installation routine plugins
* '''$INSTDIR''' : files used during the installation
* '''$_OUTDIR''' : files to be installed.
The generated installer includes command line arguments in order to give users more control:<ref name=installerUsage>{{cite web|url=http://nsis.sourceforge.net/Docs/Chapter3.html#installerusage|title=installerUsage|publisher=NSIS}}</ref>
* '''/NCRC''' disables the CRC check, unless the script forces it
* '''/S''' runs the installer/uninstaller silently.
* '''/D''' sets the default installation directory. It must be the last parameter and must not contain any quotes. Only absolute paths are supported.
==Unicode support==
Versions of NSIS before 3.0 did not support Unicode, but only a means to convert some files to different encodings via a plugin.<ref>{{cite web|url=http://nsis.sourceforge.net/Unicode_plug-in|title=Unicode plug-in|publisher=NSIS}}</ref> However, a variant of NSIS that has full Unicode support is available.<ref>{{cite web|url=http://www.scratchpaper.com|title=Unicode NSIS Project Page}}</ref> Notable projects using this variant are:<ref>{{cite web|url=http://www.scratchpaper.com/home/shameless-promotion|title=Unicode NSIS Project Users|access-date=2 April 2010|archive-date=16 July 2011|archive-url=https://web.archive.org/web/20110716021951/http://www.scratchpaper.com/home/shameless-promotion|url-status=dead}}</ref>
*[[Google]] ([[Picasa]])
*[[Apache OpenOffice]] for Windows
*[[Mozilla]] ([[Firefox]], [[Mozilla Thunderbird]])
*[[FileZilla]]
*[[Winamp]]
*[[Flickr]]
*[[PortableApps.com]]
*[[Second Life]]
*[[Xampp]]
*[[AVG (software)|AVG]]
*[[TeamViewer]]
With the release of version 3.0 of NSIS, Unicode support can be implemented using the compiler directive "Unicode true". This gives full Unicode support with no further code changes, but the installer will not run under Windows 95/98/Me.<ref>{{cite web|title=NSIS Users Manual Chapter 1|url=http://nsis.sourceforge.net/Docs/Chapter1.html#intro-unicode|website=NSIS|access-date=26 May 2015}}</ref> As of 2016 before the 3.0 release NSIS was available in the [[PortableApps.com|PortableApps]] format for Unicode 2.46.5 Rev 3 and ANSI 2.51.<ref>{{cite web
|url=http://portableapps.com/apps/development/nsis_portable|title=NSIS Portable|publisher=[[PortableApps.com]]|date=2016-05-19|access-date=2016-07-04}}</ref>
==See also==
|