Skip to main content

How to create a quick installer to deploy your apps using Null Soft Scriptable Installer System (NSIS) – It is Small, Free and flexible

imageBased on a recent announcement from Microsoft, Visual Studio Installer will be retiring after VS2010. So it seems that in future versions of Visual Studio, Visual Studio installer won’t be available.

Background Information

From ClickOnce and Setup & Deployment projects thread

In Visual Studio 2010, we have partnered with Flexera, makers of InstallShield, to create InstallShield Limited Edition 2010 just for Visual Studio 2010 customers. The InstallShield Limited Edition 2010 offers comparable functionality to the Visual Studio Installer projects. In addition, you can build your deployment projects using Team Foundation Server and MSBuild. For more information, see this post. With InstallShield available, the Visual Studio Installer project types will not be available in future versions of Visual Studio.

So, you are expected to switch to Install Shield for your setup and deployment, if you are presently relying on Visual Studio Installer. In this post, let us explore Nullsoft Scriptable Installer System or NSIS as an alternate, open source option for packaging and deploying your applications.

Nullsoft Scriptable Installer System or NSIS – A Quick Look

If you’ve ever installed WinAmp, NSIS is the installer used by WinAmp. I used Null Soft Installer for the first time way back in 2004, when I was doing some shareware business. I had a product called Smart Editor Professional (Still available as a freeware in sites Tucows) which was developed in VC++ and VB – and I used Nullsoft NSIS for scripting the installation procedure, which included copying files, showing a splash screen, registering ActiveX dlls, providing optional install components, Creating Program menu entries, Associating file types etc. One of the most interesting aspect of NSIS is the small installer footprint, and the easy to understand scripting aspect.

Now, to start with, you need to download and install NSIS from here. Once  you finish the installation, select NSIS from your StartMenu->Programs, to bring up the NSIS menu.


A lot of resources are already listed there, but I’ll provide a quick start. You’ll find two options under the compiler – to (1) Compile NSI scripts, or to (2) Create an installer based on a Zip file. If your requirements are minimum or if you need to create an installer that’ll simply extract files from a Zip file to some where, you can try the second option. Otherwise, you can write a NSIS script (a simple text based script file with extension *.nsi) to configure the installer as you need.

Once you have an NSIS file, you can create the installer by ‘compiling’ it. Click ‘Compile NSI scripts’, to bring up NSI Script compiler.


Now, As you can imagine, you need to create an *.NSI script that directs your installer how to package your components, that can be compiled with MakeNSISW. There are tones of examples available in Program Files\NSIS\Examples folder and the User Manual is pretty comprehensive - so I’m not going to actual scripting part here. Basically, an NSIS script file has the following components.

  • Attributes – Defines the basic attributes like Name, UI etc of your installer
  • Pages – Predefined Wizard pages like directory (to allow users to select target folder for installation), components (for allowing users to select components/sections to install), etc
  • Sections – Lets you logically group your installation components, so that users can choose optional items to install. The script inside a Section is executed only if the user select that component.
  • Functions – Functions contains code like Sections, and can be called using the ‘Call’ keyword from with in sections. Also, there are callback functions with special names that the installer will invoke by itself (eg: .onInit);

Creating a simple script and an Installer

With that information, let us create a simple NSI file. Open notepad, and copy and paste the below script. If you want a decent editor for NSIS scripts, Notepad++ already supports NSIS syntax. The below script demonstrates most of the points I described earlier. Basically, it’ll create an installer by packaging all files from your c:\inst folder, and will deploy those files to a target folder specified by your user. Note that in NSIS a ; is for specifying a single line comment.

; Installer Attributes

; Name of installer
Name "NsisDemo"

; The file to write
OutFile "NsisDemo.exe"

; The default installation directory
InstallDir $PROGRAMFILES\NsisDemo

; Request application privileges for Windows Vista
RequestExecutionLevel user

; Pages

Page components
Page directory
Page instfiles


; The stuff to install
Section "Stuff" 
 ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  ;Include files from this location, and copy that to the current
  ;out path
  File c:\inst\*.*
SectionEnd ; end the section

; Functions
Function .onInit
  MessageBox MB_YESNO "This will install Xyz. Do you want to continue?" IDYES startnow

Note that we’ve three ‘Pages’ - components, directory and instfiles specified. Also, we’ve a section “Stuff”, where we use File directive for informing the NSIS compiler which all Files to package (all files in your c:\inst\*.*) - so that those files will be carried by our installer. Also, there is a callback function .onInit, which will be called automatically by installer, to get an assertion from the user – Whether to continue or not - when the installer is initialized .


  • Save the above script to a *.NSI file.
  • Place few files in the c:\inst folder (Create that folder if it is not there), so that the MakeNSIS can pick files from there to package.
  • Then compile the NSI file either by right clicking and choosing ‘Compile with NSIS’ or by opening it in the MakeNSISW Script compiler (see above).

You’ll see the generated installer exe, NsisDemo.exe, as we specified in the Installer Attributes. Now, if you run the Exe, you’ll see the following screens.

1 - This is triggered by our script in .onInit


2 – Once you click Yes, this is the ‘component’ Page. See the section ‘Stuff’ inside that.


3 – Click Next to see the ‘directory’ Page. See that what ever we specified using InstallDir installer attribute has appeared as the default destination folder.


Please note that NSIS is customizable and open source. A lot of other UIs and Plugins are also available – so don’t get deceived by the above ‘minimal’ look of the installer.

Also, you should, see this post where I explain How to use NSIS to create an offline installer for a Silverlight application. Happy Coding!!

Popular posts from this blog

MVVM - Binding Multiple Radio Buttons To a single Enum Property in WPF

I had a property in my View Model, of an Enum type, and wanted to bind multiple radio buttons to this.

Firstly, I wrote a simple Enum to Bool converter, like this.

public class EnumToBoolConverter : IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (parameter.Equals(value)) return true; else return false; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return parameter; } #endregion }

And my enumeration is like

public enum CompanyTypes { Type1Comp, Type2Comp, Type3Comp } Now, in my XAML, I provided the enumeration as the ConverterParameter, of the Converter we wrote earlier, like

Creating a quick Todo listing app on Windows using IIS7, Node.js and Mongodb

As I mentioned in my last post, more and more organizations are leaning towards Web Oriented Architecture (WOA) which are highly scalable. If you were exploring cool, scalable options to build highly performing web applications, you know what Node.js is for.After following the recent post from Scott Hanselman, I was up and running quickly with Node.js. In this post, I’ll explain step by step how I’ve setup Node.js and Mongodb to create a simple Todo listing application.Setting up Node.jsThis is what I’ve done.1 – Goto, scroll down and download node.exe for Windows, and place it in your c:\node folder2 – Goto IIS Node project in Git at, download the correct ‘retail’ link of IIS Node zip file (I downloaded the already built retail package, otherwise you can download and build from the source).3 – Extract the zip file some where, and run the install.bat or install_iisexpress.bat depending on your IIS Version. If you don’t have IIS in…

Top 7 Coding Standards & Guideline Documents For C#/.NET Developers

Some time back, I collated a list of 7 Must Read, Free EBooks for .NET Developers, and a lot of people found it useful. So, I thought about putting together a list of Coding Standard guidelines/checklists for .NET /C# developers as well.As you may already know, it is easy to come up with a document - the key is in implementing these standards in your organization, through methods like internal trainings, Peer Reviews, Check in policies, Automated code review tools etc. You can have a look at FxCop and/or StyleCop for automating the review process to some extent, and can customize the rules based on your requirements.Anyway, here is a list of some good Coding Standard Documents. They are useful not just from a review perspective - going through these documents can definitely help you and me to iron out few hidden glitches we might have in the programming portion of our brain. So, here we go, the listing is not in any specific order.1 – IDesign C# Coding StandardsIDesign C# coding stand…