Wednesday, January 18, 2012

Using InnoSetup Preprocessor (ISPP) to generate section parameters

Until now we have used Media Player Classic HC for media playback. However, we were getting more and more complains in the last time that some files couldn’t be played so we decided to switch to VideoLAN VLC player.

What we needed was a silent install and that the the player does not ask the user anything. Or in other words: Open the file and shut up.

Looking at the information about silent installation (for example here), I ended up using the “no installer” download from VLC and creating my own setup with InnoSetup. The basic script was created in no time (copying the files to \Program Files\, creating Icons etc.) but when it comes to the file association part, it was getting a little bit ugly.

First, in order to disable the default “Privacy Dialog” (once on first startup) as well as the automatic update check, you need to use this monster command line:

{pf}\VideoLAN\VLC\vlc.exe --no-qt-privacy-ask --no-qt-updates-notif --started-from-file "%1"

Given that I will need this command line later on more often I defined a ISPP constant for it on top of the ISS file:

#define StartFileCommand '{pf}\VideoLAN\VLC\vlc.exe --no-qt-privacy-ask --no-qt-updates-notif --started-from-file ""%1""'

This allows me to insert the rather long command by just typing {#StartFileCommand}:


(Yes, I know this would also be possible by using a function within the [Code] section, but I think #define is easier).

InnoSetup will expand {#StartFileCommand} to “{pf}\VideoLAN\VLC\vlc.exe … ” before it compiles, so this is what is compiled:


With this in place, it was time to create the registry entries for the files we want to open with VLC. Each file type needs to have a “Play2” command (in order to prevent overwriting any file association from an existing program) and the user should be able to use the “Open with…” list to open a file with VLC.

This results in the following four registry lines for each file type:


The only difference for any other file type would be a different subkey value (.WAV, .DIVX, etc.), all other lines would remain the same. ISPP can also be used to generated several lines at once, so I just created a user defined macro that generates these lines at once:


Within the [Registry] section I can now just write:

#define public FileExtension ".wav"
#expr RegFileAssoc

#define public FileExtension ".mpg"
#expr RegFileAssoc

ISPP will then generate the following lines automatically upon compilation:


If I ever need to change something on these registry entries, I only need to make the change once and recompiled. Supporting another file type is easy, too.


A final tip: InnoSetup has no build-in option to display the resulting ISS file when preprocessing is finished. To create this file, just enter the following command as the really last line within your ISS file:

#expr SaveToFile(AddBackslash(SourcePath) + "zz_Preprocessed.iss")

This will generate the file zz_Preprocessed.iss in the same folder where your ISS file is stored.


  1. Patrick SczepanskiWednesday, July 18, 2012

    Great post, thank you.

    Specifically how to dump the compiled iss file

  2. Excelente ejemplo para ahorrar trabajo, muchas gracias