Getting Started with Inno Setup

For the first time in years, I needed to distribute my application to the end user’s machine via an online download.  To do this effectively and professionally, I, of course, needed an install package.  Over the year, I have used both Wise and InstallShield but they both cost money and I don’t recall them being all that easy to manage.  This was, however, years ago.  More recently I have, like many developers, used Windows Installer to imagegenerate MSIs for very simple (read: file copy) deployments. There’s nothing flexible or particularly pleasing about MSIs, but one can typically get them created with a few button clicks.  For the installation of internal applications, MSIs are more than tolerable, in my opinion.  Other than those options, I was quite ignorant on the subject of installers so I briefly evaluated three free candidates:

  • Windows Installer XML (WiX) Toolset is a Microsoft open source project used to create the Office 2007 installer. WiX includes some advanced capabilities, but it has a steep learning curve even though the scripting language is XML-based.
  • NSIS (Nullsoft Scriptable Install System) is a professional open source system to create Windows installers. It is designed to be as small and flexible as possible and is therefore very suitable for Internet distribution. It has a rich feature list, a good set of online samples and a good community following.
  • Inno Setup is another free, open source installer for Windows programs. First introduced in 1997, Inno Setup today rivals and even surpasses many commercial installers in feature set and stability.

Decision

After a quick review of each product, I opted to run with Inno Setup primarily because it had the ugliest website, all of their product award links are broken and it isn’t known by any acronym…yet.  Joking aside, I chose Jordan Russell’s Inno Setup because it met all of my requirements almost effortlessly.  Here’s the rundown of what I needed:

  • Check for the .NET Framework and install if not found
  • Check if Remote Registry is running and start if stopped.
  • Check is UAC is enabled and provide user dialogue.
  • Open website(s).
  • Create quick launch, desktop, start icons.
  • Read, update registry.
  • Ask custom questions and manage response.
  • Launch applications.
  • Install silently.
  • Create associated uninstaller.
  • Show/acknowledge terms of service.
  • Display readme.
  • Customizable/skinnable display.  
  • Etc

Additionally, Inno Setup it is such an easy tool to use and test and it has been around for a long while and has a great feature list:

  • Support for all versions of Windows in use today: Vista, XP, 2008, 2003, 2000, Me, 98, 95, and NT 4.0. (No service packs are required.)
  • Extensive support for installation of 64-bit applications on the 64-bit editions of Windows. Both the x64 and Itanium architectures are supported. (On the Itanium architecture, Service Pack 1 or later is required on Windows Server 2003 to install in 64-bit mode.)
  • Supports creation of a single EXE to install your program for easy online distribution. Disk spanning is also supported.
  • Standard Windows 2000/XP-style wizard interface.
  • Customizable setup types, e.g. Full, Minimal, Custom.
  • Complete uninstall capabilities.
  • Installation of files:
    Includes integrated support for “deflate”, bzip2, and 7-Zip LZMA file compression. The installer has the ability to compare file version info, replace in-use files, use shared file counting, register DLL/OCX’s and type libraries, and install fonts.
  • Creation of shortcuts anywhere, including in the Start Menu and on the desktop.
  • Creation of registry and .INI entries.
  • Integrated Pascal scripting engine.
  • Support for multilingual installs.
  • Support for passworded and encrypted installs.
  • Silent install and uninstall.
  • Full source code is available (Borland Delphi 2.0-5.0).

Oh, and have I mentioned that it is free? 

Getting Started

The basic installer includes the Inno Setup Compiler, documentation and numerous samples.  If you want to get started quickly just download Inno Setup and review the sample scripts.  You’ll be creating your own installers in no time.  Alternatively, you could download/install the QuickStart Pack, but I honestly do not think it is necessary.image

As I mentioned, a review/compilation of the samples can provide a quick, easy introduction into the impressive tool. All the examples are worth a look, but I feel it is necessary to give a few special mention:

  • Example1.iss, Example2.iss and Example3.iss provide a great foundation as they demonstrate how to access the registry, add a desktop icon, include a readme file, etc, etc, etc.  
  • If you are planning to do anything non-standard, play around with the CodeExample1.iss sample.  It essentially builds a basic setup, captures every installer event, includes custom functions, and demonstrates how to extract/expand files, display dialogues and issue before and after installer actions. 
  • Finally, if you want to build custom pages, check out CodeDlg.iss which demonstrates how to build installer pages with custom questions and user input options.

My suggestion is to review the samples from within the Compiler.  The Compiler doesn’t have intellisense or anything, but it will obviously validate your script and call out where imageinvalid syntax exists.  The Compiler also allows you to immediately “run” your installer script (by clicking on the green arrow button) or compile the script (by clicking on the fourth button from the left.) What the heck is that anyway?  The Compile IDE is a fancy notepad with options and actions.  It’s simple and I dig it.

Speaking of simple, here’s an example script.  You would have to build on its foundation if you wanted to do anything fancy, like read from the registry, but these few lines practically do it all.  They copy three files into the Program Files sub directory, displays a read me file and add an icon to the Start Menu.  And all the standard installer pages (splash, location, completion, etc) comes along for free — free meaning no effort and no code.

[Setup] AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output

[Files] Source: “MyProg.exe”; DestDir: “{app}”
Source: “MyProg.chm”; DestDir: “{app}”
Source: “Readme.txt”; DestDir: “{app}”; Flags: isreadme

[Icons] Name: “{group}\My Program”; Filename: “{app}\MyProg.exe”

Extra Help

Finding the right syntax wasn’t always a breeze as everything isn’t covered in the samples.  With that said, the best online reference I found was an Inno Setup Manual hosted at AgentSoft.com. I can’t say I know the connection between AgentSoft and Inno but I’m still very happy to have found the reference.  I also found various “real world” installer scripts, like this one, posted online which really helped facilitate my ramp up.

.NET Framework Install Script

In my requirements list, I called out the need to check for the .NET Framework and install if it wasn’t found.  This functionality is a snap using Inno Setup — just be sure to use the Client Profile version of the installer.

[Files] Source: “Executables\dotnetfx35setup.exe”; DestDir: “{tmp}”; Flags: deleteafterinstall

[Run] Filename: {tmp}\dotnetfx35setup.exe; Parameters: “/Q /NORESTART”; Check: Is35FrameworkInstalled; Flags: runhidden shellexec waituntilterminated; StatusMsg: “This may forever.”

[Code] function Is35FrameworkInstalled():Boolean;
begin
    Result := not RegKeyExists(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Net Framework Setup\NDP\v3.5′);
end;

Summary

I’ll keep it short and sweet: Inno Setup is one slick piece of software that made the dreaded task of creating a custom installer one heck of a lot easier than it could have been.  I’ve added Inno Setup to my toolbox and I highly suggest you do too.

Comments

  1. Hi Dear Moderator,
    I just wanted the code under Inno Setup for adding the
    1. Quick Launch Icon,
    2. Desktop Icon
    3. Autorun

    with examples for my installer , I am trying but i am unable to get the logic.
    Please help me ASAP.

    Thanks.

  2. Hi Dear Moderator,
    I just wanted the code under Inno Setup for adding the
    1. Quick Launch Icon,
    2. Desktop Icon
    3. AutoStart up

    with examples for my installer , I am trying but i am unable to get the logic.Its very urgent.
    Please help me ASAP.

    Thanks.

  3. Hi.

    I am new to inno setup program. I want little help sir,
    I want to create a setup that will not ask for DefaultDirLocation
    the Setup will extract all the files to system32 directory. So the user cannot change its default path.

  4. hi i need a help

    i hv developed a MS access database system in C sharp . net

    after thet i created a setup in innosetup. its vs installed success fully . after dat whn i click the icon on desktop its showing database error any solution ?

  5. Nazmy: it would help to know the error message, but it might be related to where the file was installed. Depending on OS and user rights, some locations are read-only by the user, and this will cause errors with Access applicaitons. In Inno, just use {localappdata) and things will be handled correctly in at least XP/Vista/7 (haven’t been able to test others)

  6. Worthless tips, just like thousands of tips out there in the web. I haven’t seen anyone write anything about unpacking your own zip file. This is the most dificult thing to do.

  7. Hi Ben,

    Thanks for an excellent article. I have used Inno Setup for several years now, and the possibilities are endless.

    Anyways, all you of asking support questions here on this blog, would probably be better of using the news group forums which you can find here : http://www.jrsoftware.org/newsgroups.php

    All the best
    Jan

    May your coding be prosperous and divined (not to mention: bug free :o)

  8. While I’ve used InnoSetup for a long time, I LOVE ISTool! The interface is so easy I have people with very limited computer skills using it!

  9. Hi there. I discovered your blog by means of Google at the same time as searching for a related subject, your web site got here up. It appears to be great. I have bookmarked it in my google bookmarks to come back later.

closed