- Details
- Written by: INsane
- Category: NSIS Installers
- Hits: 7181
This tutorial really has two new techniques you will have to master.
If you want more complicated install options you will have to learn a little more about manually assembling a NSIS script. The handy wizard can still be used but it will be slower as there will be a fair bit of cutting and pasting involved to insert sections of the script in the right places.
So we will have a deeper look at the HM NIS Edits Code Template Tool and have a go at manual NSIS scripts.
Previously I showed you how to install a Code Template using HM NIS Edits Code Template Tool. What this tool does is just help write a text file in the HM NIS Edit directory. The best way to add code snippets is still through HM NIS Edits Code Template Tool, but I just want to show you where it is and what it looks like.
Go to the directory you installed HM NIS Edit, we are looking for the Templates.dat file. The most common place is....
C:\Program Files\HMSoft\NIS Edit
Open that file with Notepad or a text editor of your choice like Notepad++. This is what you may see....
grad1
=BGGradient 0000FF 000000 FFFFFF
grad2
=BGGradient 8080FF 000000 FFFFFF
It goes on depending on how many snippets of code you have placed in there, like the steam folder function or other bits and pieces. We will have a brief look at the format this file uses.
grad1 ....(This is the title you see in the “Code Templates” of HM NIS Edit)
=BGGradient 0000FF 000000 FFFFFF ....(This is the actual line of script to be entered)
The “=” before a line means this will go in the script and it is the start of a new line.
No “=” when there is text after it means it will be ignored and it is a title that will appear in “Code Templates” of HM NIS Edits GUI.
Remember the “|” pipe symbol problem and the steam folder finder snippet we put in before? You can scroll down and see that section too.
You don’t have to edit this file, I just wanted to show you how it works and remind you about the problem this file has if code snippets have a “|” in them.... they must be finished off with a “|” on the bottom line or they will not put in the last “|” in the script!
Now you know where that file is and what it does you may like to replace it with one of mine for the next section. Just shut down HM NIS Edit and make a new folder in C:\Program Files\HMSoft\NIS Edit called “Template back up” and move Templates.dat file inside it.
Download this one and place it in C:\Program Files\HMSoft\NIS. There is a file for dod:s and CS:s, just choose the correct folder in the zip and use the Templates.dat file inside.
The new one you put in has lots of options in it now, if you see some you don’t want don’t forget you can delete them if you want through HM NIS Edit.
Start up HM NIS Edit, start a blank new script. Insert the Code Template “Steam (CS:S or DoD:S) folder finder PLUS a 6 options with a REQ, Ticked and un-ticked.”
Now select "Compile and Run". You will have to save it, just call it a name and put it on the desktop or somewhere, (like your project folder) you can find it latter. The compile process will complete and the “Tester for sections steam games” installer starts.
Press Next> and have a look at the “Choose Components” page.
Notice the first choice "Required Files" is greyed out and you can’t select or deselect it?
Look at the top section of the script...
Section "Required Files" !Required
SectionIn RO
;Put your "Required" files (like main HUD files) made from the wizard here!
;The user can't change these! No section description will be written.
SectionEnd
This just lets the user know there are files in that section.... but they are a “must have” and can not be deselected.
Go back to the installer page now, click on “option no 2”, then 3, 4, 5 and 6.
There are 2 more options that are unselected and selected by default....
Section /O "Item that is unselected" SEC07 ; Section /O = unselected
;Your files
SectionEnd
Section "Item that is selected" SEC08 ; Section = selected (Wizard default)
;Your files
SectionEnd
Notice section 7 has “/O” after “Section” ? That is how to make a section un-ticked by default.
I grabbed that and combined the steam folder finder code into it and added a normal HM NIS Edit Wizard script. Now it is a Code Template ready to....
• Add a custom message (See line 7)
• Add folder/file addresses to the sections (See line 11 to 48)
• Adjust all the Names and Pages of the Icons and Installer pages (See line 166 to 212)
• Change the un-installer icon name and adjust the section description text. (See line 217 to 250)
• Add all the uninstall file addresses. (See line 252)
Using a code snippet like this you can run through the wizard and add all the normal things... start a new one, insert a Code Template and cut and past all the Folder/File addresses, installer names and colors in to it. It’s just another way to assemble the same installer script ...but with more features the wizard won’t give you.
If you look through both scripts and go line by line for names and addresses, cut and paste until you reach the bottom...compile it and you are done! You can also make a Code Template of the completed script and keep all the folders and files you used to make this installer.... if you have a “version 2” of your content it is just a matter of replacing the source files used in your project folder and changing the names and colors in the installer.
Note: Always keep the stuff you used in the same address...otherwise, the addresses of folders and files will not be found at compile time.
NSIS Function: Be careful when using Functions in a script. An example of this is, you should not have 2 snippets of scripts with “Function .onInit” in it... it will not compile!
What I have prepared is custom set of templates that you can use, they are the steam folder finder and adjusted versions of KiCHiK’s script that have been integrated so you don’t have a mistake in the script.
How about a larger installer GUI? You can fit more in... graphically speaking and present your software with a little more pazazz. Go to the Ultra Modern UI tutorial next.
Designed by INsane Webmaster - dodbits.com using Template Toaster (Joomla! Version 4)
