Skip to content

Commit

Permalink
Display installer window when upgrading, upgrade is unattended, silen…
Browse files Browse the repository at this point in the history
…t install wont run app
  • Loading branch information
Natsumi-sama committed Dec 7, 2024
1 parent 5fa8c0f commit ad409bc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Dotnet/Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public static void Check()

private static void Install()
{
var setupArguments = "/S";
var setupArguments = string.Empty;
if (Wine.GetIfWine())
setupArguments += " /SKIP_SHORTCUT=true";
setupArguments += "/SKIP_SHORTCUT=true";

try
{
Expand Down
56 changes: 32 additions & 24 deletions Installer/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@
;--------------------------------
;Pages

!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUpgrade
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre

!define MUI_PAGE_CUSTOMFUNCTION_PRE SkipIfUpgrade
!insertmacro MUI_PAGE_DIRECTORY

!insertmacro MUI_PAGE_INSTFILES

;------------------------------
Expand All @@ -72,6 +75,8 @@
!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
Expand All @@ -89,35 +94,45 @@
;--------------------------------
;Functions

Function dirPre
StrCmp $upgradeInstallation "true" 0 +2
Function SkipIfUpgrade
StrCmp $upgradeInstallation 0 noUpgrade
Abort
noUpgrade:
FunctionEnd

Function .onInit
StrCpy $upgradeInstallation "false"
StrCpy $upgradeInstallation 0

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
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

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:
Abort
next:
StrCpy $upgradeInstallation "true"
done:
FunctionEnd

Function .onInstSuccess
${If} $upgradeInstallation = 1
Call launchVRCX
${EndIf}
FunctionEnd

Function createDesktopShortcut
CreateShortcut "$DESKTOP\VRCX.lnk" "$INSTDIR\VRCX.exe"
FunctionEnd
Expand All @@ -131,20 +146,18 @@ FunctionEnd
;Installer Sections

Section "Install" SecInstall

StrCmp $upgradeInstallation "true" 0 noupgrade
StrCmp $upgradeInstallation 0 noUpgrade
DetailPrint "Uninstall previous version..."
ExecWait '"$INSTDIR\Uninstall.exe" /S _?=$INSTDIR'
Delete $INSTDIR\Uninstall.exe
Goto afterupgrade

noupgrade:
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:
afterUpgrade:

SetOutPath "$INSTDIR"

Expand All @@ -162,9 +175,10 @@ Section "Install" SecInstall

${GetParameters} $R2
${GetOptions} $R2 /SKIP_SHORTCUT= $3
StrCmp $3 "true" +3
CreateShortCut "$SMPROGRAMS\VRCX.lnk" "$INSTDIR\VRCX.exe"
ApplicationID::Set "$SMPROGRAMS\VRCX.lnk" "VRCX"
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"
Expand All @@ -173,12 +187,6 @@ Section "Install" SecInstall
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"'

${If} ${Silent}
SetOutPath $INSTDIR
ShellExecAsUser::ShellExecAsUser "" "$INSTDIR\VRCX.exe" ""
${EndIf}

SectionEnd

;--------------------------------
Expand Down

0 comments on commit ad409bc

Please sign in to comment.