VRCX Installer 1

This commit is contained in:
Natsumi
2021-08-03 20:50:05 +12:00
parent c0b1b2d094
commit f0c8e27e40
2 changed files with 53 additions and 46 deletions
+2
View File
@@ -0,0 +1,2 @@
"C:\Program Files (x86)\NSIS\makensis.exe" installer.nsi
pause
+51 -46
View File
@@ -7,22 +7,22 @@
;-------------------------------- ;--------------------------------
;Include Modern UI ;Include Modern UI
!include "MUI2.nsh" !include "MUI2.nsh"
!include "FileFunc.nsh" !include "FileFunc.nsh"
!include "LogicLib.nsh" !include "LogicLib.nsh"
;-------------------------------- ;--------------------------------
;General ;General
!define VRCX_BASEDIR "..\bin\x64\Release" !define VRCX_BASEDIR "..\bin\x64\Release"
Unicode True Unicode True
Name "VRCX" Name "VRCX"
OutFile "VRCX_Setup.exe" OutFile "VRCX_Setup.exe"
InstallDir "$PROGRAMFILES64\VRCX" InstallDir "$PROGRAMFILES64\VRCX"
InstallDirRegKey HKLM "Software\VRCX" "InstallDir" InstallDirRegKey HKLM "Software\VRCX" "InstallDir"
RequestExecutionLevel admin RequestExecutionLevel admin
ShowInstDetails show ShowInstDetails show
;-------------------------------- ;--------------------------------
;Variables ;Variables
@@ -32,15 +32,15 @@
;-------------------------------- ;--------------------------------
;Interface Settings ;Interface Settings
!define MUI_ABORTWARNING !define MUI_ABORTWARNING
;-------------------------------- ;--------------------------------
;Pages ;Pages
!insertmacro MUI_PAGE_LICENSE "..\LICENSE" !insertmacro MUI_PAGE_LICENSE "..\LICENSE"
!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre !define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
;------------------------------ ;------------------------------
; Finish Page ; Finish Page
@@ -57,13 +57,13 @@
!insertmacro MUI_PAGE_FINISH !insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH !insertmacro MUI_UNPAGE_FINISH
;-------------------------------- ;--------------------------------
;Languages ;Languages
!insertmacro MUI_LANGUAGE "English" !insertmacro MUI_LANGUAGE "English"
;-------------------------------- ;--------------------------------
;Macros ;Macros
@@ -72,17 +72,17 @@
;Functions ;Functions
Function dirPre Function dirPre
StrCmp $upgradeInstallation "true" 0 +2 StrCmp $upgradeInstallation "true" 0 +2
Abort Abort
FunctionEnd FunctionEnd
Function .onInit Function .onInit
StrCpy $upgradeInstallation "false" StrCpy $upgradeInstallation "false"
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "UninstallString" ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "UninstallString"
StrCmp $R0 "" done StrCmp $R0 "" done
; If VRCX is already running, display a warning message and exit ; If VRCX is already running, display a warning message and exit
StrCpy $1 "VRCX.exe" StrCpy $1 "VRCX.exe"
nsProcess::_FindProcess "$1" nsProcess::_FindProcess "$1"
Pop $R1 Pop $R1
@@ -91,19 +91,19 @@ Function .onInit
Abort Abort
${EndIf} ${EndIf}
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION "VRCX is already installed. $\n$\nClick `OK` to upgrade the existing installation or `Cancel` to cancel this upgrade." /SD IDOK IDCANCEL cancel
"VRCX is already installed. $\n$\nClick `OK` to upgrade the \ Goto next
existing installation or `Cancel` to cancel this upgrade." \ cancel:
IDOK upgrade Abort
Abort next:
upgrade: StrCpy $upgradeInstallation "true"
StrCpy $upgradeInstallation "true"
done: done:
FunctionEnd FunctionEnd
Function createDesktopShortcut Function createDesktopShortcut
CreateShortcut "$DESKTOP\VRCX.lnk" "$INSTDIR\VRCX.exe" CreateShortcut "$DESKTOP\VRCX.lnk" "$INSTDIR\VRCX.exe"
FunctionEnd FunctionEnd
Function launchVRCX Function launchVRCX
@@ -116,40 +116,45 @@ FunctionEnd
Section "Install" SecInstall Section "Install" SecInstall
StrCmp $upgradeInstallation "true" 0 noupgrade StrCmp $upgradeInstallation "true" 0 noupgrade
DetailPrint "Uninstall previous version..." DetailPrint "Uninstall previous version..."
ExecWait '"$INSTDIR\Uninstall.exe" /S _?=$INSTDIR' ExecWait '"$INSTDIR\Uninstall.exe" /S _?=$INSTDIR'
Delete $INSTDIR\Uninstall.exe Delete $INSTDIR\Uninstall.exe
Goto afterupgrade Goto afterupgrade
noupgrade: noupgrade:
afterupgrade: afterupgrade:
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
File /r /x *.json /x *.sqlite3 /x *.pdb /x userdata /x cache "..\bin\x64\Release\*.*" File /r /x *.json /x *.sqlite3 /x *.pdb /x userdata /x cache "..\bin\x64\Release\*.*"
WriteRegStr HKLM "Software\VRCX" "InstallDir" $INSTDIR WriteRegStr HKLM "Software\VRCX" "InstallDir" $INSTDIR
WriteUninstaller "$INSTDIR\Uninstall.exe" WriteUninstaller "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "DisplayName" "VRCX" 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" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "DisplayIcon" "$\"$INSTDIR\VRCX.ico$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "DisplayIcon" "$\"$INSTDIR\VRCX.ico$\""
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2 ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0 IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "EstimatedSize" "$0" WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" "EstimatedSize" "$0"
CreateShortCut "$SMPROGRAMS\VRCX.lnk" "$INSTDIR\VRCX.exe" CreateShortCut "$SMPROGRAMS\VRCX.lnk" "$INSTDIR\VRCX.exe"
ApplicationID::Set "$SMPROGRAMS\VRCX.lnk" "VRCX" ApplicationID::Set "$SMPROGRAMS\VRCX.lnk" "VRCX"
${If} ${Silent}
SetOutPath $INSTDIR
ShellExecAsUser::ShellExecAsUser "" "$INSTDIR\VRCX.exe" ""
${EndIf}
SectionEnd SectionEnd
;-------------------------------- ;--------------------------------
;Uninstaller Section ;Uninstaller Section
Section "Uninstall" Section "Uninstall"
; If VRCX is already running, display a warning message and exit ; If VRCX is already running, display a warning message and exit
StrCpy $1 "VRCX.exe" StrCpy $1 "VRCX.exe"
nsProcess::_FindProcess "$1" nsProcess::_FindProcess "$1"
Pop $R1 Pop $R1
@@ -158,11 +163,11 @@ Section "Uninstall"
Abort Abort
${EndIf} ${EndIf}
RMDir /r "$INSTDIR" RMDir /r "$INSTDIR"
DeleteRegKey HKLM "Software\VRCX" DeleteRegKey HKLM "Software\VRCX"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VRCX"
Delete "$SMPROGRAMS\VRCX.lnk" Delete "$SMPROGRAMS\VRCX.lnk"
Delete "$DESKTOP\VRCX.lnk" Delete "$DESKTOP\VRCX.lnk"
SectionEnd SectionEnd