A few weeks ago I had to fix an Inno Setup script.

It was my first time writing code in Pascal Script, and my first time working with Inno Setup. It was a fun experience and I learned a few new things.

Today I wanted to write down some of my learnings to have them as a reference for the future, and to share them in case anyone trying to update an installer script for the first time could find them useful.

Documentation

The Inno Setup documentation is available online and also in the Inno Setup app by going to Help > Inno Setup Documentation (or pressing F1). For some reason, it was easier for me to find things in the Desktop app.

It is worth mentioning that sometimes the docs refer to files in the installation folder (the “Examples” subfolder or the ““ISPPBuiltins.iss” file), so you have to find your installation folder (mine was at %localappdata%\Programs\Inno Setup 6) or use as a reference the online repository (I leave links to the “Examples” dir and “ISPPBuiltins.iss” file).

Comment: if you want to save the link to a specific section of the online documentation, right-click the link on the web page and choose “Copy Link” - otherwise when using left clicks, the URL remains the same.

ISPP and Pascal Script

When working with the .iss I had to work with Pascal Script code and Preprocessor code.

For me, Pascal Script is easier to write, but the Preprocessor code has the advantage of allowing you to do compile-time tasks. The truth is that the online community around Inno Setup is very strong, and most of the common problems have already been solved and their solutions are available online.

Global Settings

The [Setup] section contains global settings - here is where I used preprocessor code the most.

I think that maybe this is one of the places where the power of Inno Setup shows. There are a lot of different directives and by setting them a lot can be achieved without much code.

Constants

It is important to understand how to access these constants using ExpandConstant.

The constant that called my attention the most was {tmp} because it is not the value of the user’s TEMP environment variable, so it can be confusing.

Command line options

The command line parameters are listed here.

If using /SUPPRESSMSGBOXES parameter, you need to use the suppressible msg boxes.

When using /LOG parameter you get more information than the entries you log manually with the Log function, which is cool.

Notes on Pascal Script

I’ll be brief because I don’t want to replicate the docs here.

I got stuck a few times because of using = instead of := to assign a variable. This got specially confusing when jumping between setting the global settings at [Setup] section and after working with Pascal Script in other sections.

I think I would most of the time add a BoolToStr function as per here to work more comfortably.

Conclusion

Inno Setup is an amazing tool. At first glance, I didn’t feel very excited about coding in Pascal Script, but when I realized how good the tool is and how strong the online community around it is, I realized I’m very lucky I got to work with it. I would recommend it to anyone thinking of creating a Windows installer.