Author: b.henry 03/19/2021
Language:
NSIS
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 Modern User Interface
;Written by Brian Henry
!include nsDialogs.nsh
!include LogicLib.nsh
Unicode True
;--------------------------------
;Version Information
;Version "1.0.0.3"
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
;--------------------------------
;General
;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
!define MUI_ABORTWARNING
;--------------------------------
;Pages
!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_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
Section "Youe App Name" SecDummy
SetOutPath "$INSTDIR"
;Delete Old FILES HERE...
Delete "$INSTDIR\*.*"
;ADD YOUR OWN FILES HERE...
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"
SectionEnd
;--------------------------------
;Descriptions
;Language strings
LangString DESC_SecDummy ${LANG_ENGLISH} "Installs the main program for Youe App Name."
;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;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"
RMDir /r /REBOOTOK "$INSTDIR"
DeleteRegKey /ifempty HKCU "Software\Youe App Name"
SectionEnd