Untitled

  • Uploaded by: wang
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Untitled as PDF for free.

More details

  • Words: 984
  • Pages: 2
As the name suggests, NSIS uses scripts which are ultimately compiled into a final executable. As with all things code-wise, there’s a specific format NSIS requires, and the easiest way to learn this structure is to build a sample install file – so let’s get to it! First, grab NSIS from nsis.sourceforge.net and install it. While you can do everything from a text editor of your choice, if you want to make life easy as well as have the benefit of context sensitive highlighting, grab HM NIS EDIT from hmne.sourceforge.net – we’ll be using it for this tutorial. First we need to prepare our files we want to install. Create a folder, and copy in the files you wish to be installed. These will eventually be called into the script for compression into a single executable. For the sake of this article, let’s assume they’re called ‘Morris.txt’, ‘MrsMorris.jpg’ and ‘MorrisJnr.hint’. Open up HM NIS Edit. Go to File --> New Script From Wizard, and enter the appropriate details. This will set up the header of the installation script for you. We’ve named ours Atomic Installer, but you’re welcome to use anything you like. Choose the modern GUI, and alter any other settings you desire. Next we get to choose the installation directory, by default $PROGRAMFILES\Name of Program. $PROGRAMFILES is for all intents and purposes a symbolic link or variable – wherever this symbol appears, the installer queries the operating system as to where the program files directory exists, and then adjusts its output appropriately. Not only does this mean portability across configurations, but more often than not it means less typing! Always a bonus. Whatever you enter here will then be stored as the symbol $INSTDIR. Several other symbols also exist that can be used throughout your code – see the sidebox on the next page for the most commonly used ones. On the same dialog, you can include a license if you want, to be displayed inside the installer – simply leave the field blank if you wish to skip it. Click Next and hit the Add File button (the second white page icon), and add all of the files we moved into our folder earlier. Check ‘Allow user to select the components to install’. Now we need to set up any Start Menu icons that we wish to install. Creating an internet shortcut will do as it says, using the website details you entered on the first page, and is selected by default. Click the New Shortcut button. Use the lower drop down box to select the file you wish to appear in the Start Menu, then select $SMPROGRAMS from the top drop down menu. You’ll want to alter the string to include your program folder – so for our install, if we wanted to create a shortcut to ‘MorrisJnr.hint’ in the Start Menu with a more descriptive name, we’d enter something like $SMPROGRAMS\Atomic Install\MorrisJnr I Am Your Father.lnk. You can also set up any desktop icons in the same manner by using the $DESKTOP symbol instead. Skip the next step for now, hit Next at the window after that and then hit Finish. Script Revision Holy crap on toast! That’s a lot of code. Let’s take a look at the different sections that have been generated. The first section is simply the information we entered on the first page of the wizard, with additional uninstall data being written to the registry. Next we’re including the libraries required to use the Modern UI (MUI.nsh). ! define MUI_ABORTWARNING tells the installer to display an ‘Are you sure?’ style message when the users tries to cancel. Following this are our install icons and uninstall icons – in the modern UI, the install icon will appear as the icon for

the program, in the title bar of the program and as an image in the top right. Be aware that your install and uninstall icons must contain the same number of icons, in the same size and colour depth order. If this makes no sense to you, that’s okay, just play it safe and use the default icon set or any of the matching sets provided in the ‘\Contrib\Graphics\Icons\’ subfolder off your NSIS directory. Following this we have what pages will appear in the installer, and in what order. By default there’s Welcome screen, followed by a screen allowing the user to install the components they wish, then a screen allowing the choice of install directory. MUI_PAGE_INSTFILES is the install progress page, then we have the finish page, the uninstaller page and the language file. The !define key that you see littered all about the place is essentially creating a symbol – if you use the symbol ${PRODUCT_NAME} after using !define PRODUCT_NAME, it will link back to the PRODUCT_NAME argument you entered at the top of the script, in this case ‘Atomic Install’. As you can see, this methodology is used for the Name variable, which is next in the script. This is what the installer will call your program throughout the process, and include in the title bar. OutFile is the name of the executable that will be produced upon compilation (and will be generated in the same directory that your .NSI file is in), and InstallDir is where the files will be installed by default. If you comment out the MUI_PAGE_DIRECTORY macro earlier with a semicolon, the files will be force installed to the default directory. Next up is ShowInstDetails and ShowUnInstDetails, which have the arguments Show, Hide, and NeverShow. Show displays the details as the program installs, Hide displays a progress bar with a button to ‘Show Details’ if the user desires, and NeverShow displays only a progress bar with no option to view the install process. Note that you can get all the valid arguments for an instruction at any time by hovering the mouse over it in HM NIS Edit.

Related Documents

Untitled
June 2020 0
Untitled
June 2020 0
Untitled
June 2020 0
Untitled
June 2020 0
Untitled
June 2020 0
Untitled
June 2020 0

More Documents from ""

November 2019 20
Untitled
April 2020 21
Why's Screen Cast
June 2020 6
Rg.251045050.pdf
December 2019 11
August 2019 10
Denon Avr S930h Manual.pdf
December 2019 10