Latest Uploads
Extraterre ... .0.1 (zip)

dantheman363

Monty Teas ... Screenie 1

steve_ancell

Santa Clau ... ed his bag

waroffice

manic_platdude.png

spinal

Tetris Clone

steve_ancell

Super blues bros.

spinal

Articles + Tutorials > Presentation and Organisation ( Created 03 April 2012 | Last Edited 03 April 2012)

Scripting installers with NSIS by Afr0 | No Votes
Learning the NSIS-script language
Written in
Other
If you need an installer for your game, you probably need it to be customisable so that it can do the things you want. Don't worry - NSIS to the rescue!

The scripting language used by NSIS is quite simple, and though the syntax isn't the best, it is easy to understand and learn.

Let's look at some code...

-->

First of all, you should include "LogicLib.nsh". It contains if, elseif and endif macros (I know, the language doesn't come with these!!)
The Name command specifies the name of your installer as it appears when the user starts it.
The OutFile command specifies the name of the created executable.
RequestExecutionLevel is used for Vista and Win7 to request an execution level under UAC.
I'm actually not sure what the Page command does, but I believe it adds a predefined dialog to the installer.
You can use the Var command to create variables. These are not type-specific.

In order to implement functions, you can use the Function command. Functions can also override globally available functions. For instance, .onInit is executed as the installer starts up.

-->

As you can see, reading the registry is a piece of cake! The ReadRegStr command takes three parameters;

  • A string to read into
  • The registry folder to read
  • The key to read!

  • $INSTDIR is a global string that can be used to keep track of the installation directory.
    There's also $PROGRAMFILES, $PROGRAMFILES32 and $PROGRAMFILES64 to keep track of where "Program Files" is on the current computer.

    You can split an installation into sections using the Section command;

    -->

    Here you can see that there's another global variable called $TEMP that keeps track of where a Windows' temp directory is.
    The File command is perhaps the most important command in the language. When the compiler encounters it, it takes the specified file and compresses it into the final executable. However, upon script execution, this command extracts that very same file to wherever SetOutPath was pointed to.
    ExecWait pauses the installation and executes the specified executable - this is mostly useful for executing installers for libraries that your game/program depends upon.

    Below is an example of a section that creates a bunch of different folders and extracts a bunch of different files into them;

    -->

    There are no comments for this entry.
    Latest Posts
    FIRST!!!
    steve_ancell Wed 03:55
    Position in Mind
    steve_ancell Wed 03:51
    Noel's Graduation
    waroffice Wed 02:55
    Monkey vs iOS tweaks
    spinal Tue 22:51
    Fucking Pound Sign Unicode Bullshit Bollocks
    Dabz Tue 13:00
    Progress / Location Bars
    dna Tue 08:55
    Screen Burn of the Mind
    rockford Tue 02:13
    RoadRash!
    Mog Mon 10:56
    Development via GUI
    waroffice Mon 02:48
    Audio Rant
    steve_ancell Sat 19:16
    More

    Latest Items
    News : Newsletter #176
    Jayenkai Sat 04:49
    News : Newsletter #175
    Dabz Tue 09:38
    Blog : Snow: More Material Junk
    Cower Sat 23:17
    Dev-Diary : Mutant Monty: Amstrad CPC to Windows conversion
    rockford Fri 13:14
    Techy : AppleTV
    Jayenkai Thu 09:40
    Blog : Graphviz
    steve_ancell Sat 14:17
    Pets : Top-Down Shadow Hack
    Jayenkai Tue 05:52
    Snippet : JNKrunch v1.0
    Jayenkai Sat 07:20
    News : Newsletter #173
    waroffice Fri 04:47
    Blog : Material Loading
    Cower Fri 02:08
    Pets : I Done Won A Thing
    shroom_monk Sun 11:31
    Pets : Repurposing A Lexer
    Cower Mon 22:06
    Bah : Feeling a Little Angry
    spinal Mon 11:26
    News : Newsletter #170
    Dabz Sat 00:34
    Showcase : sbfgen
    Cower Sat 16:57
    More

    Who's Online
    steve_ancell
    Wed, at 04:45
    Jayenkai
    Wed, at 04:43
    shroom_monk
    Wed, at 04:38
    spinal
    Wed, at 04:24
    Afr0
    Wed, at 03:54
    waroffice
    Wed, at 03:10
    CodersRule
    Wed, at 03:01
    HoboBen
    Wed, at 02:56
    Hotshot
    Wed, at 02:45
    blanko1324
    Wed, at 01:20
    Link to this page
    Site : Jayenkai 2006-Infinity |
    MudChat's origins, BBCode's former life, Image Scaler.