;NSIS Modern User Interface ;Start Menu Folder Selection Example Script ;Written by Joost Verburg ;-------------------------------- ;Include Modern UI !include "MUI2.nsh" ;-------------------------------- ;General ;Name and file Name "Yoink" OutFile "../yoinksetup-@VERSION@.exe" SetCompressor /SOLID lzma ;Default installation folder InstallDir "$PROGRAMFILES\Yoink" ;Get installation folder from registry if available InstallDirRegKey HKCU "Software\Yoink" "" ;Request application privileges for Windows Vista RequestExecutionLevel user ;-------------------------------- ;Interface Settings !define MUI_ICON "../src/setup.ico" !define MUI_UNICON "../src/uninstall.ico" !define MUI_COMPONENTSPAGE_SMALLDESC !define MUI_FINISHPAGE_RUN "$INSTDIR\yoink.exe" !define MUI_FINISHPAGE_RUN_NOTCHECKED !define MUI_FINISHPAGE_LINK "Visit the Yoink website" !define MUI_FINISHPAGE_LINK_LOCATION "http://www.dogcows.com/" !define MUI_ABORTWARNING ;-------------------------------- ;Pages !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES ;-------------------------------- ;Languages !insertmacro MUI_LANGUAGE "English" ;-------------------------------- ;Installer Sections Section "Install Yoink!" SecInstallYoink SetOutPath "$INSTDIR" ;ADD YOUR OWN FILES HERE... File /r "build/*" ;Store installation folder WriteRegStr HKCU "Software\Yoink" "" $INSTDIR ;Create uninstaller WriteUninstaller "uninstall.exe" ;Create shortcuts CreateDirectory "$SMPROGRAMS\Yoink" CreateShortCut "$SMPROGRAMS\Yoink\Play Yoink!.lnk" "$INSTDIR\yoink.exe" CreateShortCut "$SMPROGRAMS\Yoink\Uninstall.lnk" "$INSTDIR\uninstall.exe" WriteRegStr HKCU "Software\Games\Yoink" "" "$INSTDIR" WriteRegStr HKCU "Software\Games\Yoink" "Version" "@VERSION@" WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink" "DisplayName" "Yoink" WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink" "DisplayVersion" "@VERSION@" WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink" "UninstallString" "$INSTDIR\uninstall.exe" SectionEnd Section "Install desktop shortcut." SecInstallShortcut ;Desktop shortcut SetOverwrite on CreateShortCut "$DESKTOP\Yoink.lnk" "$INSTDIR\yoink.exe" SetOverwrite off SectionEnd ;-------------------------------- ;Descriptions ;Language strings LangString DESC_SecInstallYoink ${LANG_ENGLISH} "Install the game executable and data files." LangString DESC_SecInstallShortcut ${LANG_ENGLISH} "Install a shortcut to the executable on the desktop." ;Assign language strings to sections !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecInstallYoink} $(DESC_SecInstallYoink) !insertmacro MUI_DESCRIPTION_TEXT ${SecInstallShortcut} $(DESC_SecInstallShortcut) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section "Uninstall" Delete "$SMPROGRAMS\Yoink\*.*" RMDir "$SMPROGRAMS\Yoink" Delete "$DESKTOP\Yoink.lnk" DeleteRegKey /ifempty HKCU "Software\Games\Yoink" DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink" RMDir /r "$INSTDIR" SectionEnd ;-------------------------------- ;Functions Function .onInit ;Run the uninstaller if Yoink is already installed. ReadRegStr $R0 HKCU \ "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Yoink" \ "UninstallString" StrCmp $R0 "" done MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ "Yoink is already installed. $\n$\nClick `OK` to remove the \ previous version or `Cancel` to cancel the installation." \ IDOK uninst Abort ;Run the uninstaller uninst: ClearErrors ExecWait $INSTDIR\uninstall.exe done: FunctionEnd