|
| 1 | +!include "MUI2.nsh" |
| 2 | + |
| 3 | +Name Jorts |
| 4 | + |
| 5 | +Outfile "JortsInstaller.exe" |
| 6 | +InstallDir "$LOCALAPPDATA\Programs\Jorts" |
| 7 | +#RequestExecutionLevel admin ; Request administrative privileges |
| 8 | + |
| 9 | +# Set the title of the installer window |
| 10 | +Caption "Jorts Installer" |
| 11 | + |
| 12 | +# Set the title and text on the welcome page |
| 13 | +!define MUI_WELCOMEPAGE_TITLE "Welcome to Jorts setup" |
| 14 | +!define MUI_WELCOMEPAGE_TEXT "This bitch will guide you through the installation of Jorts." |
| 15 | +!define MUI_ABORTWARNING |
| 16 | +!define MUI_ABORTWARNING_TEXT "Are you sure you want to cancel Jorts setup?" |
| 17 | +!define MUI_INSTFILESPAGE_TEXT "Please wait while Jorts is being installed." |
| 18 | +!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" |
| 19 | +!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" |
| 20 | + |
| 21 | +!insertmacro MUI_PAGE_WELCOME |
| 22 | +!insertmacro MUI_PAGE_DIRECTORY |
| 23 | +!insertmacro MUI_PAGE_INSTFILES |
| 24 | +!insertmacro MUI_PAGE_FINISH |
| 25 | +!insertmacro MUI_UNPAGE_CONFIRM |
| 26 | +!insertmacro MUI_UNPAGE_INSTFILES |
| 27 | +!insertmacro MUI_UNPAGE_FINISH |
| 28 | + |
| 29 | +!insertmacro MUI_LANGUAGE "English" |
| 30 | + |
| 31 | +!macro GetCleanDir INPUTDIR |
| 32 | + ; ATTENTION: USE ON YOUR OWN RISK! |
| 33 | + ; Please report bugs here: http://stefan.bertels.org/ |
| 34 | + !define Index_GetCleanDir 'GetCleanDir_Line${__LINE__}' |
| 35 | + Push $R0 |
| 36 | + Push $R1 |
| 37 | + StrCpy $R0 "${INPUTDIR}" |
| 38 | + StrCmp $R0 "" ${Index_GetCleanDir}-finish |
| 39 | + StrCpy $R1 "$R0" "" -1 |
| 40 | + StrCmp "$R1" "\" ${Index_GetCleanDir}-finish |
| 41 | + StrCpy $R0 "$R0\" |
| 42 | +${Index_GetCleanDir}-finish: |
| 43 | + Pop $R1 |
| 44 | + Exch $R0 |
| 45 | + !undef Index_GetCleanDir |
| 46 | +!macroend |
| 47 | + |
| 48 | +; ################################################################ |
| 49 | +; similar to "RMDIR /r DIRECTORY", but does not remove DIRECTORY itself |
| 50 | +; example: !insertmacro RemoveFilesAndSubDirs "$INSTDIR" |
| 51 | +!macro RemoveFilesAndSubDirs DIRECTORY |
| 52 | + ; ATTENTION: USE ON YOUR OWN RISK! |
| 53 | + ; Please report bugs here: http://stefan.bertels.org/ |
| 54 | + !define Index_RemoveFilesAndSubDirs 'RemoveFilesAndSubDirs_${__LINE__}' |
| 55 | + |
| 56 | + Push $R0 |
| 57 | + Push $R1 |
| 58 | + Push $R2 |
| 59 | + |
| 60 | + !insertmacro GetCleanDir "${DIRECTORY}" |
| 61 | + Pop $R2 |
| 62 | + FindFirst $R0 $R1 "$R2*.*" |
| 63 | +${Index_RemoveFilesAndSubDirs}-loop: |
| 64 | + StrCmp $R1 "" ${Index_RemoveFilesAndSubDirs}-done |
| 65 | + StrCmp $R1 "." ${Index_RemoveFilesAndSubDirs}-next |
| 66 | + StrCmp $R1 ".." ${Index_RemoveFilesAndSubDirs}-next |
| 67 | + IfFileExists "$R2$R1\*.*" ${Index_RemoveFilesAndSubDirs}-directory |
| 68 | + ; file |
| 69 | + Delete "$R2$R1" |
| 70 | + goto ${Index_RemoveFilesAndSubDirs}-next |
| 71 | +${Index_RemoveFilesAndSubDirs}-directory: |
| 72 | + ; directory |
| 73 | + RMDir /r "$R2$R1" |
| 74 | +${Index_RemoveFilesAndSubDirs}-next: |
| 75 | + FindNext $R0 $R1 |
| 76 | + Goto ${Index_RemoveFilesAndSubDirs}-loop |
| 77 | +${Index_RemoveFilesAndSubDirs}-done: |
| 78 | + FindClose $R0 |
| 79 | + |
| 80 | + Pop $R2 |
| 81 | + Pop $R1 |
| 82 | + Pop $R0 |
| 83 | + !undef Index_RemoveFilesAndSubDirs |
| 84 | +!macroend |
| 85 | + |
| 86 | +Section "Install" |
| 87 | + SetOutPath "$INSTDIR" |
| 88 | + File /r "windows\deploy\*" |
| 89 | + CreateDirectory $SMPROGRAMS\Jorts |
| 90 | + |
| 91 | + ; Start menu |
| 92 | + CreateShortCut "$SMPROGRAMS\Jorts\Jorts.lnk" "$INSTDIR\bin\jorts.exe" "" "$INSTDIR\windows\jorts.ico" 0 |
| 93 | + |
| 94 | + ; Autostart |
| 95 | + ; CreateShortCut "$SMPROGRAMS\Startup\Jorts.lnk" "$INSTDIR\bin\jorts.exe" "" "$INSTDIR\windows\jorts.ico" 0 |
| 96 | + |
| 97 | + ; Preferences |
| 98 | + CreateShortCut "$SMPROGRAMS\Jorts\Preferences of Jorts.lnk" "$INSTDIR\bin\jorts.exe" "--preferences" "$INSTDIR\windows\jorts.ico" 0 |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + WriteRegStr HKCU "Software\Jorts" "" $INSTDIR |
| 103 | + WriteUninstaller "$INSTDIR\Uninstall.exe" |
| 104 | + |
| 105 | + ; Add to Add/Remove programs list |
| 106 | + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jorts" "DisplayName" "Jorts" |
| 107 | + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jorts" "UninstallString" "$INSTDIR\Uninstall.exe" |
| 108 | +SectionEnd |
| 109 | + |
| 110 | +Section "Uninstall" |
| 111 | + |
| 112 | + ; Remove Start Menu shortcut |
| 113 | + Delete "$SMPROGRAMS\Jorts\Jorts.lnk" |
| 114 | + Delete "$SMPROGRAMS\Startup\Jorts.lnk" |
| 115 | + |
| 116 | + ; Remove uninstaller |
| 117 | + Delete "$INSTDIR\Uninstall.exe" |
| 118 | + |
| 119 | + ; Remove files and folders |
| 120 | + !insertmacro RemoveFilesAndSubDirs "$INSTDIR" |
| 121 | + |
| 122 | + ; Remove directories used |
| 123 | + RMDir $SMPROGRAMS\Jorts |
| 124 | + RMDir "$INSTDIR" |
| 125 | + |
| 126 | + ; Remove registry keys |
| 127 | + DeleteRegKey HKCU "Software\Jorts" |
| 128 | + DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Jorts" |
| 129 | + |
| 130 | +SectionEnd |
| 131 | + |
0 commit comments