-
Notifications
You must be signed in to change notification settings - Fork 0
/
QuizMasterApprentice.nsi
168 lines (117 loc) · 4.77 KB
/
QuizMasterApprentice.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
;NSIS Modern User Interface
;Quiz Master's Apprentice Script
;Written by Paul Voelker
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
!define MUI_ICON ".\QMA.ico"
!define MUI_UNICON ".\QMAUninstall.ico"
;--------------------------------
!define APP_NAME "Quiz Masters Apprentice"
!define APP_FULL_NAME "Quiz Master's Apprentice"
;--------------------------------
;General
!getdllversion ".\QuizMastersApprenticeApp\bin\Release\net7.0-windows\QMA.exe" MyVer_
;Name and file
Name "Quiz Master's Apprentice v${MyVer_1}.${MyVer_2}"
OutFile "QMAInstall.exe"
VIProductVersion "${MyVer_1}.${MyVer_2}.${MyVer_3}.${MyVer_4}"
VIAddVersionKey ProductName "Quiz Master's Apprentice Install"
VIAddVersionKey FileVersion "${MyVer_1}.${MyVer_2}.${MyVer_3}.${MyVer_4}"
VIAddVersionKey ProductVersion "${MyVer_1}.${MyVer_2}.${MyVer_3}.${MyVer_4}"
VIAddVersionKey FileDescription "Installation Package for Quiz Master's Apprentice"
VIAddVersionKey LegalCopyright "Copyright © 2023 Paul Voelker"
;Default installation folder
InstallDir "$PROGRAMFILES\${APP_NAME}"
;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\${APP_NAME}" ""
;Request application privileges for Windows Vista
RequestExecutionLevel admin
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;--------------------------------
;Pages
;!insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
;!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
Section
SetOutPath "$INSTDIR"
File .\QuizMastersApprenticeApp\bin\Release\net7.0-windows\*.exe
File .\QuizMastersApprenticeApp\bin\Release\net7.0-windows\*.dll
File .\QuizMastersApprenticeApp\bin\Release\net7.0-windows\*.runtimeconfig.json
SetOutPath "$INSTDIR\Help"
File .\QuizMastersApprenticeApp\bin\Release\net7.0-windows\Help\*.html
;Store installation folder
WriteRegStr HKCU "Software\${APP_NAME}" "" $INSTDIR
;'Programs and Features' entry (http://nsis.sourceforge.net/Add_uninstall_information_to_Add/Remove_Programs)
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
"DisplayName" "Quiz Master's Apprentice"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
"Publisher" "Paul Voelker"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
"UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
"QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
"DisplayIcon" "$\"$INSTDIR\QMA.exe$\""
; Start Menu
CreateDirectory "$SMPROGRAMS\${APP_NAME}"
CreateDirectory "$SMPROGRAMS\${APP_NAME}\Help"
CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk" "$INSTDIR\QMA.exe"
;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd
;--------------------------------
;Descriptions
;Language strings
;LangString DESC_SecDummy ${LANG_ENGLISH} "A test section."
;Assign language strings to sections
;!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
;!insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
;!insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
; Start Menu
Delete "$SMPROGRAMS\${APP_NAME}\${APP_NAME}.lnk"
RmDir "$SMPROGRAMS\${APP_NAME}"
Delete "$INSTDIR\Uninstall.exe"
Delete "$INSTDIR\*.exe"
Delete "$INSTDIR\*.dll"
Delete "$INSTDIR\*.runtimeconfig.json"
Delete "$INSTDIR\Help\*.html"
RmDir "$INSTDIR\Help"
RmDir "$INSTDIR"
DeleteRegKey /ifempty HKCU "Software\${APP_NAME}"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
SectionEnd
;--------------------------------
Function .onInit
ReadRegStr $R0 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}" \
"QuietUninstallString"
StrCmp $R0 "" done
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"'${APP_FULL_NAME}' is already installed. $\n$\nClick `OK` to remove the \
previous version or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort
;Run the uninstaller
uninst:
ClearErrors
Exec $R0
done:
FunctionEnd
;--------------------------------
; Sign installer and uninstaller
!finalize 'signfile.bat "QMAInstall.exe"'
!uninstfinalize 'signfile.bat "%1"'