Blame | Last modification | View Log | RSS feed
;-------------------------------------------------------------------------------;; Example of a NSIS basis Windows Installer suitable for use within the; Vix-ERG environment;; This is an example of how things can be done; It includes a lot of excess documentation that can be removed;;--------------------------------; Include Modern UI; Provides an Installer that is similar to many other Windows-XP installers!include "MUI2.nsh";--------------------------------; General; Specify basic settings;; Name - Already set based on package name and version; BrandingText - Already set; Caption - Already set; FileDescription; Will be available when the user selects the properties; of the installer. All other properties have been set based the; package name and version.;VIAddVersionKey "FileDescription" "ArmCompiler 251"; Default installation folder; Sets $INSTDIR;InstallDir "C:\ARM251"; Get installation folder from registry if available!define InstallDirReg "Software\Vix-ERG\ArmCompiler-251"InstallDirRegKey HKCU ${InstallDirReg} ""; Request application privileges for Windows VistaRequestExecutionLevel admin; Program Group for Shortcuts!define ProgramGroupBase "BuildTools"!define ProgramGroup "${ProgramGroupBase}\ArmCompiler-251";; This is NOT a VIX piece of Software; Don't brand it as such.; Don't know where it came from - just created an installer to ensure that it; can be installed!undef GBE_COMPANY!define GBE_COMPANY "Legacy Installer";--------------------------------; Modern Interface Settings#!define MUI_ABORTWARNING# !define MUI_ICON "${GBE_NSISDATA}\VixIcon.ico"# !define MUI_UNICON "${GBE_NSISDATA}\VixIcon.ico"!define MUI_HEADERIMAGE# !define MUI_HEADERIMAGE_BITMAP "${GBE_NSISDATA}\VixHeader.bmp"# !define MUI_WELCOMEFINISHPAGE_BITMAP "${GBE_NSISDATA}\VixPanel.bmp"# !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${GBE_NSISDATA}\VixPanel.bmp"!define MUI_FINISHPAGE_NOAUTOCLOSE!define MUI_UNFINISHPAGE_NOAUTOCLOSE!define MUI_WELCOMEPAGE_TITLE_3LINES!define MUI_FINISHPAGE_TITLE_3LINES;--------------------------------; Pages; List of Pages for the Modern UI to show!insertmacro MUI_PAGE_WELCOME#!insertmacro MUI_PAGE_LICENSE "${GBE_NSISDATA}\license.txt"#!insertmacro MUI_PAGE_COMPONENTS#!insertmacro MUI_PAGE_DIRECTORY!insertmacro MUI_PAGE_INSTFILES#!insertmacro MUI_PAGE_FINISH#!insertmacro MUI_UNPAGE_WELCOME!insertmacro MUI_UNPAGE_CONFIRM#!insertmacro MUI_UNPAGE_COMPONENTS!insertmacro MUI_UNPAGE_INSTFILES#!insertmacro MUI_UNPAGE_FINISH;--------------------------------; Languages; System will select default language!insertmacro MUI_LANGUAGE "English"!insertmacro MUI_LANGUAGE "French"# !insertmacro MUI_LANGUAGE "Swedish";--------------------------------; Allow user to select the language#Function .onInit# !insertmacro MUI_LANGDLL_DISPLAY#FunctionEnd#Function un.onInit# !insertmacro MUI_LANGDLL_DISPLAY#FunctionEnd;--------------------------------; Installer Sections; Each section will show up as a 'component', if that page is shown;Section "Application" SecDummySetOutPath "$INSTDIR"; Install a programCreateDirectory "$INSTDIR"IfErrors 0 +2Abort "Error creating application directory structure"SetOutPath "$INSTDIR"File /r "ARM251\*"IfErrors 0 +2Abort "Error installing application files"; Create a Short CutSetShellVarContext allCreateDirectory "$SMPROGRAMS\${ProgramGroup}"CreateShortCut "$SMPROGRAMS\${ProgramGroup}\UnInstall ArmCompiler.lnk" "$INSTDIR\Uninstall.exe"IfErrors 0 +2Abort "Error creating shortcuts"IfErrors 0 +2Abort "Error Installing Application"SectionEnd;--------------------------------;Uninstaller Sections; Un Installer for files installed by the user;Section "un.Application";; Remove the programRMDir /r "$INSTDIR"SetShellVarContext allRMDir /r "$SMPROGRAMS\${ProgramGroup}"RMDir "$SMPROGRAMS\${ProgramGroupBase}"SectionEnd;--------------------------------; Section to create the Core of the Uninstaller; This will be hiddenSection "-Core";Store installation folderWriteRegStr HKCU ${InstallDirReg} "" $INSTDIR;Create uninstaller and copy it into the install directorySetOutPath "$INSTDIR"WriteUninstaller "$INSTDIR\Uninstall.exe"; Write the uninstall keys for Windows so that the package is seen in the; Add/Remove Program section of the Control Panel.; Create a 'unique' key in the windows registry; Base it on the package name; Could use a GUID but it MUST NOT be copied if this file is copied;!define UnInstallKeyBase "Software\Microsoft\Windows\CurrentVersion\Uninstall"!define UnInstallKey "${UnInstallKeyBase}\${GBE_PACKAGE}"WriteRegStr HKLM ${UnInstallKey} "DisplayName" "${GBE_PACKAGE}, ${GBE_VERSION}"WriteRegStr HKLM ${UnInstallKey} "Version" "${GBE_VERSION}"WriteRegStr HKLM ${UnInstallKey} "DisplayVersion" "${GBE_VERSION_FULL}"WriteRegStr HKLM ${UnInstallKey} "Publisher" "${GBE_COMPANY}"WriteRegStr HKLM ${UnInstallKey} "InstallLocation" "$INSTDIR"WriteRegStr HKLM ${UnInstallKey} "UninstallString" '"$INSTDIR\uninstall.exe"'WriteRegDWORD HKLM ${UnInstallKey} "NoModify" 1WriteRegDWORD HKLM ${UnInstallKey} "NoRepair" 1SectionEnd;--------------------------------; Uninistaller section to uninstall keys; That have been installed as a part of the core installer;Section "-un.Core"; Delete the uninstaller and then the containing directory; The directory will only be removed if its emptyDelete "$INSTDIR\Uninstall.exe"RMDir "$INSTDIR"; Remove the programs registry keyDeleteRegKey /ifempty HKCU ${InstallDirReg}; Remove Uninstaller registry keysDeleteRegKey HKLM ${UnInstallKey}SectionEnd