forked from vrcx-team/VRCX
-
Notifications
You must be signed in to change notification settings - Fork 5
/
installer.nsi
215 lines (167 loc) · 6.27 KB
/
installer.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
;--------------------------------
;Plugins
;https://nsis.sourceforge.io/ApplicationID_plug-in
;https://nsis.sourceforge.io/ShellExecAsUser_plug-in
;https://nsis.sourceforge.io/NsProcess_plugin
;https://nsis.sourceforge.io/Inetc_plug-in
;--------------------------------
;Version
!define PRODUCT_VERSION "1.0.0.0"
!define VERSION "1.0.0.0"
VIProductVersion "${PRODUCT_VERSION}"
VIFileVersion "${VERSION}"
VIAddVersionKey "FileVersion" "${VERSION}"
VIAddVersionKey "ProductName" "VRCX"
VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
VIAddVersionKey "LegalCopyright" "Copyright vrcx-team, pypy, natsumi"
VIAddVersionKey "FileDescription" "Friendship management tool for VRChat"
;--------------------------------
;Include Modern UI
!include "MUI2.nsh"
!include "FileFunc.nsh"
!include "LogicLib.nsh"
;--------------------------------
;General
Unicode True
Name "VRCX"
OutFile "VRCX_Setup.exe"
InstallDir "$PROGRAMFILES64\VRCX"
InstallDirRegKey HKLM "Software\VRCX" "InstallDir"
RequestExecutionLevel admin
ShowInstDetails show
;--------------------------------
;Variables
VAR upgradeInstallation
;--------------------------------
;Interface Settings
!define MUI_ABORTWARNING
;--------------------------------
;Icons
!define MUI_ICON "../VRCX.ico"
!define MUI_UNICON "../VRCX.ico"
;--------------------------------
;Pages
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUpgrade
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUpgrade
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
;------------------------------
; Finish Page
; Checkbox to launch VRCX.
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Launch VRCX"
!define MUI_FINISHPAGE_RUN_FUNCTION launchVRCX
; Checkbox to create desktop shortcut.
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create desktop shortcut"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION createDesktopShortcut
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUpgrade
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Macros
;--------------------------------
;Functions
Function SkipIfUpgrade
StrCmp $upgradeInstallation 0 noUpgrade
Abort
noUpgrade:
FunctionEnd
Function .onInit
StrCpy $upgradeInstallation 0
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "UninstallString"
StrCmp $R0 "" notInstalled
StrCpy $upgradeInstallation 1
notInstalled:
; If VRCX is already running, display a warning message
loop:
StrCpy $1 "VRCX.exe"
nsProcess::_FindProcess "$1"
Pop $R1
${If} $R1 = 0
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "VRCX is still running. $\n$\nClick `OK` to kill the running process or `Cancel` to cancel this installer." /SD IDOK IDCANCEL cancel
nsExec::ExecToStack "taskkill /IM VRCX.exe"
${Else}
Goto done
${EndIf}
Sleep 1000
Goto loop
cancel:
Abort
done:
FunctionEnd
Function .onInstSuccess
${If} $upgradeInstallation = 1
Call launchVRCX
${EndIf}
FunctionEnd
Function createDesktopShortcut
CreateShortcut "$DESKTOP\VRCX.lnk" "$INSTDIR\VRCX.exe"
FunctionEnd
Function launchVRCX
SetOutPath $INSTDIR
ShellExecAsUser::ShellExecAsUser "" "$INSTDIR\VRCX.exe" ""
FunctionEnd
;--------------------------------
;Installer Sections
Section "Install" SecInstall
StrCmp $upgradeInstallation 0 noUpgrade
DetailPrint "Uninstall previous version..."
ExecWait '"$INSTDIR\Uninstall.exe" /S _?=$INSTDIR'
Delete $INSTDIR\Uninstall.exe
Goto afterUpgrade
noUpgrade:
inetc::get "https://aka.ms/vs/17/release/vc_redist.x64.exe" $TEMP\vcredist_x64.exe
ExecWait "$TEMP\vcredist_x64.exe /install /quiet /norestart"
Delete "$TEMP\vcredist_x64.exe"
afterUpgrade:
SetOutPath "$INSTDIR"
File /r /x *.log /x *.pdb "..\bin\x64\Release\*.*"
WriteRegStr HKLM "Software\VRCX" "InstallDir" $INSTDIR
WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "DisplayName" "VRCX"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "DisplayIcon" "$\"$INSTDIR\VRCX.ico$\""
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "EstimatedSize" "$0"
${GetParameters} $R2
${GetOptions} $R2 /SKIP_SHORTCUT= $3
StrCmp $3 "true" noShortcut
CreateShortCut "$SMPROGRAMS\VRCX.lnk" "$INSTDIR\VRCX.exe"
ApplicationID::Set "$SMPROGRAMS\VRCX.lnk" "VRCX"
noShortcut:
WriteRegStr HKCU "Software\Classes\vrcx" "" "URL:vrcx"
WriteRegStr HKCU "Software\Classes\vrcx" "FriendlyTypeName" "VRCX"
WriteRegStr HKCU "Software\Classes\vrcx" "URL Protocol" ""
WriteRegExpandStr HKCU "Software\Classes\vrcx\DefaultIcon" "" "$INSTDIR\VRCX.ico"
WriteRegStr HKCU "Software\Classes\vrcx\shell" "" "open"
WriteRegStr HKCU "Software\Classes\vrcx\shell\open" "FriendlyAppName" "VRCX"
WriteRegStr HKCU "Software\Classes\vrcx\shell\open\command" "" '"$INSTDIR\VRCX.exe" /uri="%1" /params="%2 %3 %4"'
SectionEnd
;--------------------------------
;Uninstaller Section
Section "Uninstall"
; If VRCX is already running, display a warning message and exit
StrCpy $1 "VRCX.exe"
nsProcess::_FindProcess "$1"
Pop $R1
${If} $R1 = 0
MessageBox MB_OK|MB_ICONEXCLAMATION "VRCX is still running. Cannot uninstall this software.$\nPlease close VRCX and try again." /SD IDOK
Abort
${EndIf}
RMDir /r "$INSTDIR"
DeleteRegKey HKLM "Software\VRCX"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX"
DeleteRegKey HKCU "Software\Classes\vrcx"
${IfNot} ${Silent}
Delete "$SMPROGRAMS\VRCX.lnk"
Delete "$DESKTOP\VRCX.lnk"
${EndIf}
SectionEnd