Display installer window when upgrading, upgrade is unattended, silent install wont run app

This commit is contained in:
Natsumi
2024-12-06 11:57:36 +13:00
parent 5fa8c0f530
commit ad409bc1c3
2 changed files with 34 additions and 26 deletions
+2 -2
View File
@@ -35,9 +35,9 @@ namespace VRCX
private static void Install() private static void Install()
{ {
var setupArguments = "/S"; var setupArguments = string.Empty;
if (Wine.GetIfWine()) if (Wine.GetIfWine())
setupArguments += " /SKIP_SHORTCUT=true"; setupArguments += "/SKIP_SHORTCUT=true";
try try
{ {
+30 -22
View File
@@ -55,9 +55,12 @@
;-------------------------------- ;--------------------------------
;Pages ;Pages
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUpgrade
!insertmacro MUI_PAGE_LICENSE "..\LICENSE" !insertmacro MUI_PAGE_LICENSE "..\LICENSE"
!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUpgrade
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_INSTFILES
;------------------------------ ;------------------------------
@@ -72,6 +75,8 @@
!define MUI_FINISHPAGE_SHOWREADME !define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "Create desktop shortcut" !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create desktop shortcut"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION createDesktopShortcut !define MUI_FINISHPAGE_SHOWREADME_FUNCTION createDesktopShortcut
!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUpgrade
!insertmacro MUI_PAGE_FINISH !insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_CONFIRM
@@ -89,35 +94,45 @@
;-------------------------------- ;--------------------------------
;Functions ;Functions
Function dirPre Function SkipIfUpgrade
StrCmp $upgradeInstallation "true" 0 +2 StrCmp $upgradeInstallation 0 noUpgrade
Abort Abort
noUpgrade:
FunctionEnd FunctionEnd
Function .onInit Function .onInit
StrCpy $upgradeInstallation "false" StrCpy $upgradeInstallation 0
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 "" notInstalled
StrCpy $upgradeInstallation 1
notInstalled:
; If VRCX is already running, display a warning message ; If VRCX is already running, display a warning message
loop:
StrCpy $1 "VRCX.exe" StrCpy $1 "VRCX.exe"
nsProcess::_FindProcess "$1" nsProcess::_FindProcess "$1"
Pop $R1 Pop $R1
${If} $R1 = 0 ${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 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" nsExec::ExecToStack "taskkill /IM VRCX.exe"
${Else}
Goto done
${EndIf} ${EndIf}
Sleep 1000
Goto loop
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
Goto next
cancel: cancel:
Abort Abort
next:
StrCpy $upgradeInstallation "true"
done: done:
FunctionEnd FunctionEnd
Function .onInstSuccess
${If} $upgradeInstallation = 1
Call launchVRCX
${EndIf}
FunctionEnd
Function createDesktopShortcut Function createDesktopShortcut
CreateShortcut "$DESKTOP\VRCX.lnk" "$INSTDIR\VRCX.exe" CreateShortcut "$DESKTOP\VRCX.lnk" "$INSTDIR\VRCX.exe"
FunctionEnd FunctionEnd
@@ -131,20 +146,18 @@ FunctionEnd
;Installer Sections ;Installer Sections
Section "Install" SecInstall Section "Install" SecInstall
StrCmp $upgradeInstallation 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:
inetc::get "https://aka.ms/vs/17/release/vc_redist.x64.exe" $TEMP\vcredist_x64.exe inetc::get "https://aka.ms/vs/17/release/vc_redist.x64.exe" $TEMP\vcredist_x64.exe
ExecWait "$TEMP\vcredist_x64.exe /install /quiet /norestart" ExecWait "$TEMP\vcredist_x64.exe /install /quiet /norestart"
Delete "$TEMP\vcredist_x64.exe" Delete "$TEMP\vcredist_x64.exe"
afterupgrade: afterUpgrade:
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
@@ -162,9 +175,10 @@ Section "Install" SecInstall
${GetParameters} $R2 ${GetParameters} $R2
${GetOptions} $R2 /SKIP_SHORTCUT= $3 ${GetOptions} $R2 /SKIP_SHORTCUT= $3
StrCmp $3 "true" +3 StrCmp $3 "true" noShortcut
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"
noShortcut:
WriteRegStr HKCU "Software\Classes\vrcx" "" "URL:vrcx" WriteRegStr HKCU "Software\Classes\vrcx" "" "URL:vrcx"
WriteRegStr HKCU "Software\Classes\vrcx" "FriendlyTypeName" "VRCX" WriteRegStr HKCU "Software\Classes\vrcx" "FriendlyTypeName" "VRCX"
@@ -173,12 +187,6 @@ Section "Install" SecInstall
WriteRegStr HKCU "Software\Classes\vrcx\shell" "" "open" WriteRegStr HKCU "Software\Classes\vrcx\shell" "" "open"
WriteRegStr HKCU "Software\Classes\vrcx\shell\open" "FriendlyAppName" "VRCX" 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"' WriteRegStr HKCU "Software\Classes\vrcx\shell\open\command" "" '"$INSTDIR\VRCX.exe" /uri="%1" /params="%2 %3 %4"'
${If} ${Silent}
SetOutPath $INSTDIR
ShellExecAsUser::ShellExecAsUser "" "$INSTDIR\VRCX.exe" ""
${EndIf}
SectionEnd SectionEnd
;-------------------------------- ;--------------------------------