-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathFLCompanion.nsi
244 lines (204 loc) · 8.22 KB
/
FLCompanion.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
; FLCompanion - Installation script
!define SHARED "external"
!define TARGETDIR "Release_UNICODE"
!define MAINEXE "FLCompanion.exe"
!define COPY_EXE_VERSION
!execute '${SHARED}\bin\PETool.exe "${TARGETDIR}\${MAINEXE}" /NSIS FLCompanion.nsh'
!include "FLCompanion.nsh"
!addplugindir "${SHARED}\bin"
!define APP_GUID "FLCompanion-{0A8EB4BA-8147-460B-9B0C-6D5B32F3FF41}"
!define UNINSTALLKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_GUID}"
; General --------------------------------
;Name and file
Name "${PRODUCTNAME} ${VERSION}"
OutFile "${TAGNAME}.exe"
SetCompressor lzma
;Default installation folder
InstallDir "$PROGRAMFILES\${PRODUCTNAME}"
;Get installation folder from registry if available
InstallDirRegKey HKLM "${UNINSTALLKEY}" "InstallLocation"
BrandingText " "
XPStyle on
; UI Setup --------------------------------
; SpaceTexts none
; Pages --------------------------------
; !define MUI_PAGE_CUSTOMFUNCTION_LEAVE CheckInstalled
; !define MUI_PAGE_HEADER_TEXT "Welcome to the $(^NameDA) Setup Wizard"
; !define MUI_PAGE_HEADER_SUBTEXT "This wizard will guide you through the installation of $(^NameDA)."
; !define MUI_LICENSEPAGE_TEXT_TOP "Versions history :"
; !define MUI_LICENSEPAGE_TEXT_BOTTOM "It is recommended that you close all other applications before installation.$\r$\n$\r$\n$_CLICK"
; !define MUI_LICENSEPAGE_BUTTON "$(^NextBtn)"
; !insertmacro MUI_PAGE_LICENSE "${CUSTOEMP_DIR}\WhatsNew.txt"
; !insertmacro MUI_PAGE_DIRECTORY
; !insertmacro MUI_PAGE_INSTFILES
; !insertmacro MUI_PAGE_FINISH
PageEx license
Caption " "
;LicenseText "$(WhatsNew)" "$(^NextBtn)"
PageCallbacks "" "" CheckInstalled
LicenseData ReadMe.txt
PageExEnd
Page directory
Page instfiles
; Languages --------------------------------
LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf"
LangString WhatsNew 0 "What's new in this version:"
LangString AskUninstall 0 "A previous installation of ${PRODUCTNAME} (version $R1) was found.$\n$\nDo you want to uninstall it? (recommended)"
LangString StillActive 0 "Unable to uninstall ${PRODUCTNAME}$\nbecause the program seems to be currently running$\nor you don't have administrator rights."
LangString OnlyRecentOS 0 "${PRODUCTNAME} will only run on Windows 2000, XP or more recent"
LangString MUI_UNTEXT_ABORT_SUBTITLE 0 "Uninstall of previous version was not completed successfully."
; LoadLanguageFile "${NSISDIR}\Contrib\Language files\French.nlf"
; LangString WhatsNew 0 "Liste des nouveautés de cette version :"
; LangString AskUninstall 0 "Une précédente installation de ${PRODUCTNAME} (version $R1) a été détectée.$\n$\nVoulez-vous la désinstaller ? (recommandé)"
; LangString StillActive 0 "Impossible de désinstaller ${PRODUCTNAME}$\ncar le programme est en cours d'exécution."
; LangString OnlyRecentOS 0 "${PRODUCTNAME} ne fonctionne que sous Windows 2000, XP ou plus récent"
; LangString MUI_UNTEXT_ABORT_SUBTITLE 0 "La désinstallation de la précédente version n'a pas été terminée."
; Installer Functions --------------------------------
Var WINDOWS_VERSION
Function .onInit
InitPluginsDir
ClearErrors
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" "CurrentVersion"
IfErrors bad_windows
StrCpy $WINDOWS_VERSION $R0 1
IntOp $WINDOWS_VERSION $WINDOWS_VERSION * 100
StrCpy $R0 $R0 "" 2
IntOp $WINDOWS_VERSION $WINDOWS_VERSION + $R0
IntCmp $WINDOWS_VERSION 500 0 bad_windows
Call CheckAdmin
Return
bad_windows:
MessageBox MB_OK|MB_ICONSTOP $(OnlyRecentOS)
Abort
FunctionEnd
Function CheckAdmin
File "/oname=$PLUGINSDIR\IHelper.exe" "${SHARED}\bin\IHelper.exe"
ExecWait '"$PLUGINSDIR\IHelper.exe" /NSIS "$EXEDIR" $CMDLINE' $0
IntCmp $0 -2 +2 ; we are admin, skip Quit & proceed to installation
Quit
FunctionEnd
Function CheckInstalled
ClearErrors
ReadRegStr $R1 HKLM "${UNINSTALLKEY}" "DisplayVersion"
IfErrors uninstallOver
MessageBox MB_YESNO|MB_ICONQUESTION $(AskUninstall) /SD IDYES IDNO uninstallOver
ReadRegStr $R0 HKLM "${UNINSTALLKEY}" "UninstallString"
ReadRegStr $R1 HKLM "${UNINSTALLKEY}" "InstallLocation"
retryUninstall:
ClearErrors
CopyFiles $R0 $PLUGINSDIR\Uninstall.exe
ExecWait '"$PLUGINSDIR\Uninstall.exe" /S /SHOWPROGRESS _?=$R1'
IfErrors uninstallError
Delete "$PLUGINSDIR\Uninstall.exe"
; MessageBox MB_OK|MB_ICONINFORMATION $(MUI_UNTEXT_FINISH_SUBTITLE) /SD IDOK
Return
uninstallError:
MessageBox MB_RETRYCANCEL|MB_ICONSTOP $(MUI_UNTEXT_ABORT_SUBTITLE) /SD IDOK IDRETRY retryUninstall
Abort
uninstallOver:
FunctionEnd
; Installer Sections --------------------------------
Section "!$(^Name)"
SectionIn RO
IfSilent 0 checkInstalled
Call CheckInstalled
checkInstalled:
SetShellVarContext all
nsisDDE::Execute "${APP_GUID}" "[Quit]"
Pop $0
nsisDDE::Execute "/TOPIC=${INTERNALNAME}" "Check4Update-{6B6BDEFF-569D-449E-9707-FED242753DF2}" "[Quit]"
Pop $1
IntCmp "$0$1" 0 notRunning
DetailPrint "Exiting running instances..."
Sleep 2000
notRunning:
; Game installation is really done in Section "-Main Program" below
SectionEnd
Section "-Main Program"
SetOutPath "$INSTDIR"
WriteUninstaller "Uninstall.exe"
File "${SHARED}\bin\Check4Update.exe"
File "${TARGETDIR}\${MAINEXE}"
File "ReadMe.txt"
; remove following lines after a few updates
WriteRegStr HKCU "Software\Wizou\FLCompanion\Settings" "BaseCombo" ""
WriteRegStr HKCU "Software\Wizou\FLCompanion\Settings" "SystemCombo" ""
SectionEnd
Section "-Create Shortcuts"
CreateShortCut "$SMPROGRAMS\${PRODUCTNAME}.lnk" "$INSTDIR\${MAINEXE}"
SectionEnd
Section "-Register program information"
;Setup Add/Remove Program information
WriteRegStr HKLM "${UNINSTALLKEY}" "DisplayName" "${PRODUCTNAME} ${VERSION}"
WriteRegStr HKLM "${UNINSTALLKEY}" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "${UNINSTALLKEY}" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "${UNINSTALLKEY}" "DisplayIcon" "$INSTDIR\${MAINEXE}"
WriteRegStr HKLM "${UNINSTALLKEY}" "Publisher" "${COMPANYNAME}"
WriteRegStr HKLM "${UNINSTALLKEY}" "InstallSource" "$EXEDIR"
WriteRegStr HKLM "${UNINSTALLKEY}" "Readme" "$INSTDIR\ReadMe.txt"
!ifdef URLINFOABOUT
WriteRegStr HKLM "${UNINSTALLKEY}" "URLInfoAbout" "${URLINFOABOUT}"
!endif
!ifdef URLUPDATEINFO
WriteRegStr HKLM "${UNINSTALLKEY}" "URLUpdateInfo" "${URLUPDATEINFO}"
!endif
WriteRegStr HKLM "${UNINSTALLKEY}" "DisplayVersion" "${VERSION}"
WriteRegDWORD HKLM "${UNINSTALLKEY}" "VersionMajor" ${VERSION_MAJOR}
WriteRegDWORD HKLM "${UNINSTALLKEY}" "VersionMinor" ${VERSION_MINOR}
WriteRegDWORD HKLM "${UNINSTALLKEY}" "NoModify" 1
WriteRegDWORD HKLM "${UNINSTALLKEY}" "NoRepair" 1
SectionEnd
Section "-Finish"
SetDetailsPrint textonly
DetailPrint "Completed - Click 'Close' to run the program"
SetDetailsPrint listonly
SectionEnd
Function .onInstSuccess
; start program in user-mode
SetOutPath "$INSTDIR"
nsisDDE::Execute "IHelper-{3968D359-C488-4414-944F-C7B2AB06BA69}" 'UserExec "$INSTDIR\${MAINEXE}"'
Pop $0
IntCmp $0 0 0 0 +2
Exec "$INSTDIR\${MAINEXE}"
FunctionEnd
; Uninstaller Functions --------------------------------
Function un.onInit
InitPluginsDir
File "/oname=$PLUGINSDIR\IHelper.exe" "${SHARED}\bin\IHelper.exe"
ExecWait '"$PLUGINSDIR\IHelper.exe" /NSIS "$EXEDIR" $CMDLINE _?=$INSTDIR' $0
IntCmp $0 -2 +2 ; we are admin, skip Quit & proceed to installation
Quit
FunctionEnd
; Uninstaller Section --------------------------------
Section "Uninstall"
SetShellVarContext all
nsisDDE::Execute "${APP_GUID}" "[Quit]"
Pop $0
nsisDDE::Execute "/TOPIC=${INTERNALNAME}" "Check4Update-{6B6BDEFF-569D-449E-9707-FED242753DF2}" "[Quit]"
Pop $1
IntCmp "$0$1" 0 notRunning
DetailPrint "Exiting running instances..."
Sleep 2000
notRunning:
;Remove program files
ClearErrors
Delete "$INSTDIR\${MAINEXE}"
IfErrors 0 removeOK
MessageBox MB_OK|MB_ICONSTOP $(StillActive)
SetAutoClose true
Quit
removeOk:
Delete "$INSTDIR\ReadMe.txt"
Delete "$INSTDIR\Check4Update.exe"
Delete "$INSTDIR\Uninstall.exe"
;Remove program directory (only if directory is empty)
RMDir "$INSTDIR"
;Remove shortcuts
Delete "$SMPROGRAMS\${PRODUCTNAME}.lnk"
;Remove registration
ReadRegStr $R0 HKLM "${UNINSTALLKEY}" "InstallLocation"
StrCmp $R0 "$INSTDIR" 0 notMyPath
;Delete Add/Remove Program information
DeleteRegKey HKLM "${UNINSTALLKEY}"
notMyPath:
SectionEnd