## How to create an Installer using INNO Setup Compiler

Lots of cool and useful tips to mod either serverside or clientside

### How to create an Installer using INNO Setup Compiler

If you want to create an installer for your mod, I suggest to use "Inno",a small and handy Open source tool that allows you to write a compiler script and has many advantages over the most popular setup compiler, Clickteam.
Very impressive compression (even outsmarts WinRAR "best" compression), by far better than Clickteam
Extremely high customizability
Open Source, meaning no "CREATED WITH CLICKTEAM Free installer" ads or shit like that, just a nice and tidy setup
Creates very efficient uninstaller with installation that leaves absolutely no traces whatsoever after installation (unlike almost any other setup compiler :/ )

Downside is you only have a very basic setup wizard and have to write the rest of the compiler script on your own. Sounds "OMG, I only want an installer, not learn a whole new programming language!"? Well, calm down , Inno uses a super simple compiler language and has an excellent documentation explaining all the options.

First, grab Inno here: http://www.jrsoftware.org/isinfo.php
and install it, obviously. After you start it up, just open an empty script for now.

To make things simple, I post my own script here that I use to compile my current mod, as it has some specific Battlefield stuff already included.

Code: Select all
[Setup][Setup]AppId={{15F0DBB5-51DD-419E-8257-D8DF43A6F87B};Important: Choose Run->"Generate GUID", then you'll get a line of numbers generated. Use that and replace the AppID above with it.AppName=Battlegroup42 WGP ModAppVerName=BG42_WGP Mod v0.4AppPublisher=SenshiAppVersion=0.4AppPublisherURL=http://www.wargamer-project.deAppSupportURL=http://www.wargamer-project.deAppUpdatesURL=http://www.wargamer-project.de;Pretty self-explanatory I think. These will be used in the setup dialogues.SourceDir=g:\WGPSETUP\;Now this is very simple, but very important: Type the path here where you have stored your mod. I advise to put your mod for the install script in a separate folder. Create these subfolder structure: mods\YOURMODNAME\ . This is important for the layout of my script.DefaultDirName={reg:HKLM\Software\EA GAMES\Battlefield 1942,GAMEDIR};This sets the default installation directory. This path tells the setup to read from the registry where the user has installed BF42 and uses this as base.DefaultGroupName=Wargamer Project Battlegroup Mod;The default name for the start menu folderSetupIconFile=WGP.ico;Optional. This icon will be used for the setup.exe instead of the standard one. If you don't want/need/have one, just remove this line.WizardImageFile=Setup.bmp;Optional. This image will be put in the left part of the setup. If you don't have one, remove this line so the default will be used. Max image size: 164x314LicenseFile=G:\Inno\license.rtfInfoBeforeFile=G:\Inno\info.rtfInfoAfterFile=G:\Inno\Changelog.rtf;Optional. These three text files will be used in different parts of the installation. The License one is the one where every user has to click "Read and agreed", BeforeInfo is just info appearing before the install and AfterInfo will appear after the installation. I used my copyright statement for license, some hints on installation as beforeinfo and the mod changelog as infoafter.DirExistsWarning=no;If this would be yes, users would be warned that that "installation directory already exists. Are you sure you want to blablabla." As our registry readout is 100% correct, why bother the user with this popup?AllowNoIcons=yes;Adds an option to say "Don't create start menu entries"OutputDir=g:\innoOutputBaseFilename=BG42_WGP_v0.4;The dir and name where the setup.exe will be compiled to.Compression=lzmaSolidCompression=yes;Allows you to choose compression types. LZMA is best. If you want to squeeze out every last byte, use lzma/ultra64, but that will take unproportionally long!ShowTasksTreeLines=yesAppCopyright=Copyright (C) 2009 [WGP]Senshi[Files]Source: "Mods\BG42_WGP\Archives\*.rfa"; DestDir: "{app}\mods\BG42_WGP\Archives\"Source: "Mods\BG42_WGP\init.con"; DestDir: "{app}\mods\BG42_WGP\"Source: "Mods\BG42_WGP\serverinfo.dds"; DestDir: "{app}\mods\BG42_WGP\"Source: "Mods\BG42_WGP\WGP.ico"; DestDir: "{app}\mods\BG42_WGP\";Source: "Mods\BG42_WGP\Archives\bf1942\*.rfa"; DestDir: "{app}\Archives\bf1942"; Components: progSource: "Mods\BG42_WGP\Archives\bf1942\levels\*.rfa"; DestDir: "{app}\mods\BG42_WGP\Archives\bf1942\levels\"Source: "Mods\BG42_WGP\Movies\*.bik"; DestDir: "{app}\mods\BG42_WGP\Movies"Source: "Mods\BG42_WGP\Music\*.bik"; DestDir: "{app}\mods\BG42_WGP\Music";Now it gets interesting: Here you specify all the files that you want to be put in your setup. Source describes where the files are from and DestDir tells where they shall be installed to. {app} is the installation directory.;Take note that the Source is no absolute paths (it begins with "Mods\..." and not "C:\..." ). This means the compiler will look in the SourceDir we specified earlier and read the paths from there. That's why we set it up with mods\YOURNAME :) .;If you want to copy all files in a folder, just use wildmarks: if you use "Archives\*", all files in the Archives folder will be copied. I don't use this method as I have some other stuff stored inside these folders I don't want to get copied.[Languages];Name: "en"; MessagesFile: "compiler:Default.isl"Name: "german"; MessagesFile: "compiler:Languages\German.isl";What language should be used for the installer. I only have German included, as I only spread this in a german project. If you want multiple languages, just add more lines. English is already included, just remove the ";" comment marker in front of it.[Icons]Name: "{group}\{cm:ProgramOnTheWeb,Wargamer Project Battlegroup Mod}"; Filename: "http://www.wargamer-project.de"Name: "{group}\{cm:UninstallProgram,Wargamer Project Battlegroup Mod}"; Filename: "{uninstallexe}"Name: "{userdesktop}\Battlegroup 42 WGP"; WorkingDir: "{app}"; Filename: "{app}\bf1942.exe"; Parameters: "+game bg42_wgp"; IconFilename: "{app}\mods\BG42_WGP\WGP.ico"; Tasks: desktopicon\user; Comment: "Hiermit wird die BG-WGP-Mod direkt gestartet"Name: "{commondesktop}\Battlegroup 42 WGP"; WorkingDir: "{app}"; Filename: "{app}\bf1942.exe"; Parameters: "+game bg42_wgp"; IconFilename: "{app}\mods\BG42_WGP\WGP.ico"; Tasks: desktopicon\common; Comment: "Hiermit wird die BG-WGP-Mod direkt gestartet";Icons are shortcuts. The first two are the ones that go into the start menu, one pointing to the website (what you specified under AppPublisherURL earlier).;The second is the shortcut for the uninstaller which allows the user a clean removal of all your mod files.;Now the last two are more fancy. They are both the same (first one places the shortcut on the users' desktop only, the second on places it for all users).;These last two are shortcuts which allow to directly launch the mod. Notice that under "IconFilename" I specified a .ico file that shall be used for the shortcuts (you have to include that in the installer so the user has it too! I did that under the FILES-section: WGP.ico);Comment: is the text that appears when hovering over the shortcut with the mouse.[Tasks]Name: desktopicon; Description: "Desktopverknüpfung erstellen"Name: desktopicon\common; Description: "Für alle Benutzer"; Flags: exclusiveName: desktopicon\user; Description: "Nur für den momentanen Benutzer"; Flags: exclusive unchecked;These are two basic, but nice tasks. The first one only opens a group, actually, while the two lower ones are the options to be used for it. By setting the flags "exclusive" for both of them, the user can only select one of the two options. It doesn't make sense to place the shortcut on the user desktop and the all-user-desktop...

Grab all that and copy it into your empty script, makes it much more easy on the eyes due to syntax highlighting. I have added comment lines under each important parameter explaining what it does (comments are green).

If any code line is unclear or you want to read it up more detailed, simply open the Inno help (F1 shortcut) and use the index to search for the code, you'll get a formidable and detailed explanation of it.

Once your compiler script is finished, you only need to let it compile. There are two ways to do that: Either press the "Compile" button in the top (the one with the green diamond in it), this compiles the script to the outputdir and that's it. Or you press the big green "Run"-Button. This one also compiles the script if it wasn't done before and then fires up the setup so you can check if everything is alright. Remember: If you change data in the sourcedir and want to recheck the setup, you need to press the "Compile"-Button before hitting "Run", as the "Run"-Button only recompiles if you made changes to the script!

Senshi

Posts: 695
Joined: Sun Oct 18, 2009 1:14 pm
Location: Germany