HS Banner
NSIS Installer Script

Author: Brian Henry 03/19/2021
Language: NSIS
Views: 86
Tags: NSIS installer


NSIS (Nullsoft Scriptable Install System) is a professional open source system to create Windows installers.


NSIS (Nullsoft Scriptable Install System) is a professional open source system to create Windows installers. It is designed to be as small and flexible as possible and is therefore very suitable for internet distribution.

Being a user's first experience with your product, a stable and reliable installer is an important component of successful software. With NSIS you can create such installers that are capable of doing everything that is needed to setup your software.

NSIS is script-based and allows you to create the logic to handle even the most complex installation tasks. Many plug-ins and scripts are already available: you can create web installers, communicate with Windows and other software components, install or update shared components and more.

NSIS Wiki (sourceforge.io)

Full Source Code:
;NSIS Modern User Interface
;Written by Brian Henry

!include nsDialogs.nsh
!include LogicLib.nsh
Unicode True
;Version Information

  ;Version ""

;Include Modern UI

  !include "MUI2.nsh"


  ;Name and file
  Name "Youe App Name Setup"
  OutFile "Youe App Name Setup.exe"

  ;Default installation folder
  InstallDir "$PROGRAMFILES64\Youe App Name"

  ;Get installation folder from registry if available
  InstallDirRegKey HKCU "Software\Youe App Name" ""

  ;Request application privileges for Windows Vista
  RequestExecutionLevel admin

;Interface Settings



  !insertmacro MUI_PAGE_WELCOME
  !insertmacro MUI_PAGE_LICENSE "InstallerFilers\License.txt"

  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_DIRECTORY
  !insertmacro MUI_PAGE_INSTFILES

  !define MUI_FINISHPAGE_RUN "$INSTDIR\Youe App Name.exe"
  !define MUI_FINISHPAGE_RUN_TEXT "Start the program"

  !insertmacro MUI_PAGE_FINISH

  !insertmacro MUI_UNPAGE_WELCOME
  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_FINISH


  !insertmacro MUI_LANGUAGE "English"

;Installer Sections

Section "Youe App Name" SecDummy
  SetOutPath "$INSTDIR"
  ;Delete Old FILES HERE...
  Delete "$INSTDIR\*.*"
  File /r "C:\Users\user1\Desktop\Youe App Name\InstallerFilers\*"            

  ;Store installation folder
  WriteRegStr HKCU "Software\Youe App Name" "" $INSTDIR

  ;Create uninstaller
  WriteUninstaller "$INSTDIR\Uninstall.exe"

  ; create a shortcut in the start menu programs directory and desktop
    ; point the new shortcut at the program uninstaller
    CreateShortCut "$SMPROGRAMS\Youe App Name Uninstall.lnk" "$INSTDIR\Uninstall.exe"
    CreateShortCut "$SMPROGRAMS\Youe App Name.lnk" "$INSTDIR\Youe App Name.exe"
    SetShellVarContext all
    CreateShortCut "$DESKTOP\Youe App Name.lnk" "$INSTDIR\Youe App Name.exe"



  ;Language strings
  LangString DESC_SecDummy ${LANG_ENGLISH} "Installs the main program for Youe App Name."

  ;Assign language strings to sections
    !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)

;Uninstaller Section

Section "Uninstall"

  ;Delete FILES HERE...
  Delete "$INSTDIR\*.*"
  ;second, remove the link from the start menu and desktop
  Delete "$SMPROGRAMS\Youe App Name Uninstall.lnk"
  Delete "$SMPROGRAMS\Youe App Name.lnk"
  SetShellVarContext all
  Delete "$DESKTOP\Youe App Name.lnk"

  Delete "$INSTDIR\Uninstall.exe"


  DeleteRegKey /ifempty HKCU "Software\Youe App Name"


Add Comment
There are no comments yet.