NSIS stands for Nullsoft Scriptable Install System. It is a professional script-driven open source system to create installers for Microsoft Windows and an alternative to commercial products like InstallShield. Here I present step by step how to create simple Windows installer for my project usb-cubby which saves passwords and personal information in encrypted way. First of all I downloaded and installed NSIS. Installed NSIS is 32-bit application and in C:\Program Files (x86) looks like this:
Next I created simple NSI script for usb-cubby installation packaging. I will not explain all syntax details of NSI scripting language, it is pretty simple for more details visit Scripting Reference. My NSI scripts has basic functions: specifies list of installation sequences defined by insertmacro, defines installer file name OutFile, name of installation directory InstallDir, installation section with input file and one callback function .onInstSuccess which displays a message box:
!include MUI.nsh !include “FileFunc.nsh” !include “LogicLib.nsh” !include “WordFunc.nsh” Name “usb-cubby Installer” OutFile “usb-cubbySetup.exe” Caption “usb-cubby setup” !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_LANGUAGE “English” InstallDir “$PROGRAMFILES\usb-cubby\” ;Installer Sections Section “Install” SecInstall SetOutPath “$INSTDIR” File usb-cubby.exe SectionEnd Function .onInstSuccess MessageBox MB_OK “You have successfully installed usb-cubby.exe in $INSTDIR.” FunctionEnd |
The script was saved as usb-cubby.nsi file.
To create installer right click on the usb-cubby.nsi file in File Explorer and select “Compile NSIS script” from context menu:
Output of script compilation:
Compilation shows warning that uninstaller section is not found, it is because it is not specified in the script code. The result of script compilation is usb-cubbySetup.exe, this file can be opened by 7z utility to view its contents:
To install usb-cubby.exe double click on usb-cubbySetup.exe file and follow the steps defined in the usb-cubby.nsi script:
When installation is completed check the usb-cubby is installed in directory defined in NSIS script: