;------------------------------------------------------------------------------- ; ; 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" "InstallShield StandAlone Builder" ; Default installation folder ; Sets $INSTDIR ; InstallDir "$PROGRAMFILES\Macrovision" ; Get installation folder from registry if available !define InstallDirReg "Software\Vix-ERG\IS11.5SABuild" InstallDirRegKey HKCU ${InstallDirReg} "" ; Request application privileges for Windows Vista RequestExecutionLevel admin ; Program Group for Shortcuts !define ProgramGroupBase "InstallShield" !define ProgramGroup "${ProgramGroupBase}\IS11.5 StandAlone Builder" ;-------------------------------- ; 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" SecDummy SetOutPath "$INSTDIR" ; Install a program CreateDirectory "$INSTDIR" IfErrors 0 +2 Abort "Error creating application directory structure" SetOutPath "$INSTDIR" File /r "IS11.5SA\Macrovision\IS 11.5 StandaloneBuild" File "IS11.5SA\Macrovision\*.pdf" IfErrors 0 +2 Abort "Error installing application files" ; Create a Short Cut SetShellVarContext all CreateDirectory "$SMPROGRAMS\${ProgramGroup}" CreateShortCut "$SMPROGRAMS\${ProgramGroup}\UnInstall IS11.5SABuilder.lnk" "$INSTDIR\Uninstall.exe" IfErrors 0 +2 Abort "Error creating shortcuts" IfErrors 0 +2 Abort "Error Installing Application" SectionEnd ;-------------------------------- ;Uninstaller Sections ; Un Installer for files installed by the user ; Section "un.Application" ; ; Remove the program RMDir /r "$INSTDIR" SetShellVarContext all RMDir /r "$SMPROGRAMS\${ProgramGroup}" RMDir "$SMPROGRAMS\${ProgramGroupBase}" SectionEnd ;-------------------------------- ; Section to create the Core of the Uninstaller ; This will be hidden Section "-Core" ;Store installation folder WriteRegStr HKCU ${InstallDirReg} "" $INSTDIR ;Create uninstaller and copy it into the install directory SetOutPath "$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" 1 WriteRegDWORD HKLM ${UnInstallKey} "NoRepair" 1 SectionEnd ;-------------------------------- ; 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 empty Delete "$INSTDIR\Uninstall.exe" RMDir "$INSTDIR" ; Remove the programs registry key ; Keep around for next time ; DeleteRegKey /ifempty HKCU ${InstallDirReg} ; Remove Uninstaller registry keys DeleteRegKey HKLM ${UnInstallKey} SectionEnd