Advanced Welcome/Finish Example Script: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
Liteshield (talk | contribs) (Created page with "= Advanced Welcome/Finish Example Script = <highlight-nsis> ;General ;Name and file Name "Advanced" OutFile "Advanced.exe" ;Change the default Modern UI icons ;!d...") |
Liteshield (talk | contribs) m (Liteshield moved page Advanced WelcomeFinish to Advanced Welcome/Finish Example Script) |
Revision as of 18:59, 18 July 2014
Advanced Welcome/Finish Example Script
;General ;Name and file Name "Advanced" OutFile "Advanced.exe" ;Change the default Modern UI icons ;!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue.ico" ;!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\classic-uninstall.ico" ;Default installation folder InstallDir "$PROGRAMFILES\$(^Name)" ;Get installation folder from registry if available InstallDirRegKey HKCU "Software\$(^Name)" "" !define UninstName "Uninstall" ;-------------------------------- ;Include Modern UI and Unistaller Data !include "MUI2.nsh" ;!include "UnInst.nsh" ;-------------------------------- ;Variables Var StartMenuFolder ;-------------------------------- ;Interface Settings !define MUI_ABORTWARNING !define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\win.bmp" !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\win.bmp" ;!define MUI_HEADERIMAGE ;!define MUI_HEADERIMAGE_RIGHT ;!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis.bmp" ;!define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_FINISHPAGE_RUN "$INSTDIR\Advanced.exe" ;!define MUI_FINISHPAGE_RUN_NOTCHECKED !define MUI_FINISHPAGE_SHOWREADME !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut" !define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDesktopShortCut !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED !define MUI_FINISHPAGE_LINK "nsis.sourceforge.net" !define MUI_FINISHPAGE_LINK_LOCATION "http://nsis.sourceforge.net" ShowInstDetails show ;ShowUninstDetails show ;-------------------------------- ;Language Selection Dialog Settings ;Remember the installer language and select it by default ;(should be set before installation page) !define MUI_LANGDLL_REGISTRY_ROOT "HKCU" !define MUI_LANGDLL_REGISTRY_KEY "Software\$(^Name)" !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language" ;Always show the language selection dialog (override the stored value) !define MUI_LANGDLL_ALWAYSSHOW ;Don't filter languages according to their codepage ;!define MUI_LANGDLL_ALLLANGUAGES ;-------------------------------- ;Macros !macro MUI_FINISHPAGE_SHORTCUT !ifndef MUI_FINISHPAGE_NOREBOOTSUPPORT !define MUI_FINISHPAGE_NOREBOOTSUPPORT !ifdef MUI_FINISHPAGE_RUN !undef MUI_FINISHPAGE_RUN !endif !endif !define MUI_PAGE_CUSTOMFUNCTION_SHOW DisableCancelButton !insertmacro MUI_PAGE_FINISH !define MUI_PAGE_CUSTOMFUNCTION_SHOW DisableBackButton Function DisableCancelButton EnableWindow $mui.Button.Cancel 0 FunctionEnd Function DisableBackButton EnableWindow $mui.Button.Back 0 FunctionEnd !macroend ;-------------------------------- ;Pages !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY ;Start Menu Folder Page Configuration !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\$(^Name)" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder !insertmacro MUI_PAGE_INSTFILES ;Create desktop ShortCut before reboot ;!insertmacro MUI_FINISHPAGE_SHORTCUT !insertmacro MUI_PAGE_FINISH ;Uninstaller pages !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH ;-------------------------------- ;Language Include !insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "Russian" !insertmacro MUI_LANGUAGE "Korean" ;-------------------------------- ;Reserve Files ;If you are using solid compression this will make installer start faster ;!insertmacro MUI_RESERVEFILE_LANGDLL ;-------------------------------- ;Installer Sections Section "Advanced" Sec1 ;Make unavailable to change section state SectionIn RO ;Set output path ($OUTDIR) and create it recursively if necessary SetOutPath "$INSTDIR" ;Create exclude list (UnInst.nsh) ;!insertmacro UNINST_EXCLUDE ;Add/Install files File Advanced.nsi ;File /r App\*.* ;Use nsis7z plug-in (nsis7z.dll) to extract 7-zip archive ;(unicode version is supported in MakeNSIS v2.50 or later) ;for multi-volume distribution sort your files and archive them separately ;DetailPrint "Decompression: archive1.a2b... (1/1)" ;Nsis7z::ExtractWithDetails "$EXEDIR\archive1.a2b" "Decompression: archive1.a2b... %s" ;Use ZipDLL plug-in (ZipDLL.dll) to extract zip-archive ;ZipDLL::extractall "$EXEDIR\archive2.a2b" "$OUTDIR" ;Require additional disk space to extract the archive (size_kb) ;AddSize 1000000 ;Store uninstall data (UnInst.nsh) ;!insertmacro UNINST_DATA ;Create uninstaller WriteUninstaller "$OUTDIR\${UninstName}.exe" ;Get Start Menu Folder from registry if available !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Get section name SectionGetText ${Sec1} $0 ;Create shortcuts CreateDirectory "$SMPROGRAMS\$StartMenuFolder" CreateShortCut "$SMPROGRAMS\$StartMenuFolder\$0.lnk" "$OUTDIR\Advanced.exe" "" "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue.ico" CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$OUTDIR\${UninstName}.exe" ;Store Start Menu Folder in registry !insertmacro MUI_STARTMENU_WRITE_END ;Add to control panel programs list WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$0" "DisplayName" "$0 (remove only)" WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$0" "DisplayIcon" "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue.ico" WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$0" "UninstallString" "$OUTDIR\${UninstName}.exe" ;Extract Temporary files ;SetOutPath "$PLUGINSDIR\Resource" ;File Tmp\*.* ;Execute commands ;ExecWait 'msiexec /i PhysX-9.13.0725-SystemSoftware.msi /qb' ;ExecWait 'vcredist_x86_5069.exe /q:a /c:"msiexec /i vcredist.msi /qb"' ;SetRebootFlag true SectionEnd SectionGroup /e "Components" SecGrp1 Section "Basic" Sec2 ;SetOutPath "$INSTDIR" ;File Basic.nsi SectionEnd SectionGroupEnd ;-------------------------------- ;Descriptions ;Language strings LangString DESC_Sec1 ${LANG_ENGLISH} "Advanced Example Script (English language)." LangString DESC_Sec1 ${LANG_RUSSIAN} "Advanced Example Script (Russian language)." LangString DESC_Sec1 ${LANG_KOREAN}} "Advanced Example Script (Korean language)." ;Assign language strings to sections !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${Sec1} $(DESC_Sec1) !insertmacro MUI_DESCRIPTION_TEXT ${Sec2} "Basic Example Script." !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section Section "Uninstall" ;Require confirmation to delete every other file except installed (UnInst.nsh) ;!define UNINST_INTERACTIVE ;Terminate uninstaller if the .dat file does not exist (UnInst.nsh) ;!define UNINST_TERMINATE ;Use generated header to delete files ;!include "UnFiles.nsh" ;Remove Files with uninstaller data (UnInst.nsh) ;!insertmacro UNINST_DELETE "$INSTDIR" "${UninstName}" ;Delete files Delete "$OUTDIR\Advanced.nsi" Delete "$OUTDIR\${UninstName}.exe" ;Remove installation folder RMDir "$INSTDIR" ;IfErrors 0 +3 ;MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1 "Remove all files and folders from '$INSTDIR'?" /SD IDNO IDNO +2 ;RMDir /r /REBOOTOK "$INSTDIR" ;Delete installation folder and language from registry DeleteRegKey /ifempty HKCU "Software\$(^Name)" ;Get start menu folder !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder ;Delete shortcuts Delete "$SMPROGRAMS\$StartMenuFolder\$(^Name).lnk" Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" RMDir "$SMPROGRAMS\$StartMenuFolder" ;RMDir /r "$SMPROGRAMS\$StartMenuFolder" Delete "$DESKTOP\$(^Name).lnk" ;Remove from control panel programs list DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Advanced" SectionEnd ;-------------------------------- ;Installer Functions Function .onInit ;Display language selection dialog !insertmacro MUI_LANGDLL_DISPLAY FunctionEnd Function .onGUIEnd ;Store installation folder in registry WriteRegStr HKCU "Software\$(^Name)" "" $INSTDIR ;Escape from $PLUGINSDIR to completely remove it SetOutPath "$INSTDIR" FunctionEnd Function CreateDesktopShortCut CreateShortCut "$DESKTOP\$(^Name).lnk" "$INSTDIR\Advanced.exe" "" "${NSISDIR}\Contrib\Graphics\Icons\modern-install-blue.ico" FunctionEnd ;-------------------------------- ;Uninstaller Functions Function un.onInit ;Get stored language preference !insertmacro MUI_UNGETLANGUAGE FunctionEnd Function un.onUninstSuccess MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) uninstall complete." FunctionEnd