2222; Custom defines
2323!define NAME " OOPetris"
2424!define APPFILE " oopetris.exe"
25+ !define APP_UNINSTALLER_FILE " Uninstall.exe"
2526!define SLUG " ${NAME} v${VERSION}"
2627
2728; --------------------------------
3031Name " ${NAME}"
3132OutFile " ${NAME} Setup.exe"
3233InstallDir " $PROGRAMFILES\${NAME}"
33- InstallDirRegKey HKCU " Software\${NAME}" " "
34+ InstallDirRegKey HKCU " Software\${NAME}" " InstallDir "
3435RequestExecutionLevel admin
3536
3637; --------------------------------
@@ -62,7 +63,7 @@ RequestExecutionLevel admin
6263; --------------------------------
6364; Section - Install App, always installed
6465
65- Section " -hidden app "
66+ Section " Core App " CoreApp
6667 SectionIn RO ; Read only, always installed
6768
6869 ; install assets
@@ -86,10 +87,14 @@ Section "-hidden app"
8687 SetOutPath " $INSTDIR"
8788 File /a " ${PROJECT_SOURCE_DIR}\subprojects\discord_game_sdk-3.2.1\lib\x86_64\discord_game_sdk.dll"
8889
89- WriteRegStr HKCU " Software\${NAME}" " " $INSTDIR
90- WriteUninstaller " $INSTDIR\Uninstall.exe"
9190
91+ WriteRegStr HKCU " Software\${NAME}" " InstallDir" $INSTDIR
92+ WriteUninstaller " $INSTDIR\${APP_UNINSTALLER_FILE}"
9293
94+ ; create start menu entry
95+ CreateDirectory ' $SMPROGRAMS\${NAME}'
96+ CreateShortCut ' $SMPROGRAMS\${NAME}\${NAME}.lnk' ' $INSTDIR\${APPFILE}' " " ' $INSTDIR\${APPFILE}' 0
97+ CreateShortCut ' $SMPROGRAMS\${NAME}\Uninstall ${NAME}.lnk' ' $INSTDIR\${APP_UNINSTALLER_FILE}' " " ' $INSTDIR\${APP_UNINSTALLER_FILE}' 0
9398SectionEnd
9499
95100
@@ -105,28 +110,22 @@ Section "Additional Binaries" AdditionalBinaries
105110 ; add the bin dir to the path
106111 EnVar::SetHKCU
107112 EnVar::AddValue " Path" " $INSTDIR\bin"
108- SectionEnd
109-
110-
111113
112- ; --------------------------------
113- ; Section - Shortcut; optional, can be selected by user if he wants to have one
114-
115- Section " Desktop Shortcut" DeskShort
116- CreateShortCut " $DESKTOP\${NAME}.lnk" " $INSTDIR\${APPFILE}"
114+ ; store that this is installed
115+ WriteRegDWORD HKCU " Software\${NAME}" " AddBin" 1
117116SectionEnd
118117
119118; --------------------------------
120119; Descriptions
121120
122121; Language strings
123- LangString DESC_DeskShort ${LANG_ENGLISH} " Create Shortcut on Desktop "
122+ LangString DESC_CoreApp ${LANG_ENGLISH} " Install Core App "
124123LangString DESC_BinaryFiles ${LANG_ENGLISH} " Install (Optional) Additional Binaries"
125124
126125
127126; Assign language strings to sections
128127!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
129- !insertmacro MUI_DESCRIPTION_TEXT ${DeskShort } $(DESC_DeskShort )
128+ !insertmacro MUI_DESCRIPTION_TEXT ${CoreApp } $(DESC_CoreApp )
130129 !insertmacro MUI_DESCRIPTION_TEXT ${AdditionalBinaries} $(DESC_BinaryFiles)
131130!insertmacro MUI_FUNCTION_DESCRIPTION_END
132131
@@ -153,28 +152,43 @@ Function un.RMDirUP
153152 Skip:
154153
155154 Pop $0
156-
157155FunctionEnd
158156
159157; --------------------------------
160158; Section - Uninstaller
161159
162160Section " Uninstall"
163161
164- ; Delete Shortcut
165- Delete " $DESKTOP\${NAME}.lnk "
162+ ; Delete assets
163+ RMDir /r " $INSTDIR\assets "
166164
167- ; Delete Uninstall
168- Delete " $INSTDIR\Uninstall.exe "
165+ ; Delete executable
166+ Delete " $INSTDIR\${APPFILE} "
169167
170- ; Delete Folder
168+ ; Delete Uninstall file
169+ Delete " $INSTDIR\${APP_UNINSTALLER_FILE}"
170+
171+ ; Delete the rest of the Folder
171172 RMDir /r " $INSTDIR"
172173 ${RMDirUP} " $INSTDIR"
173174
174- DeleteRegKey /ifempty HKCU " Software\${NAME}"
175+ ; delete start menu entry
176+ Delete ' $SMPROGRAMS\${NAME}\${NAME}.lnk'
177+ Delete ' $SMPROGRAMS\${NAME}\Uninstall ${NAME}.lnk'
178+
179+ RMDir /r ' $SMPROGRAMS\${NAME}'
180+ ${RMDirUP} ' $SMPROGRAMS\${NAME}'
181+
182+ ReadRegDWORD $0 HKCU " Software\${NAME}" " AddBin"
175183
176- ; remove the bin dir from the path
177- EnVar::SetHKCU
178- EnVar::DeleteValue " Path" " $INSTDIR\bin"
184+ ${If} $0 != 0
185+ ; we have additional binaries installed
186+
187+ ; remove the bin dir from the path
188+ EnVar::SetHKCU
189+ EnVar::DeleteValue " Path" " $INSTDIR\bin"
190+ ${EndIf}
179191
192+ ; delete the whole reg key
193+ DeleteRegKey HKCU " Software\${NAME}"
180194SectionEnd
0 commit comments