mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-30 18:10:04 +08:00
fix(windows): add a fallback when Auto Launch task registration is denied
This commit is contained in:
@@ -70,6 +70,7 @@ ${StrLoc}
|
||||
|
||||
Var PassiveMode
|
||||
Var UpdateMode
|
||||
Var KeepAutoLaunch
|
||||
Var NoShortcutMode
|
||||
Var WixMode
|
||||
Var OldMainBinaryName
|
||||
@@ -333,6 +334,9 @@ Function PageLeaveReinstall
|
||||
${EndIf}
|
||||
|
||||
reinst_uninstall:
|
||||
${If} $R0 = 1
|
||||
StrCpy $KeepAutoLaunch 1
|
||||
${EndIf}
|
||||
!insertmacro CheckIfAppIsRunning "$INSTDIR\${MAINBINARYNAME}.exe" "${PRODUCTNAME}"
|
||||
|
||||
HideWindow
|
||||
@@ -345,6 +349,7 @@ Function PageLeaveReinstall
|
||||
ReadRegStr $4 SHCTX "${MANUPRODUCTKEY}" ""
|
||||
ReadRegStr $R1 SHCTX "${UNINSTKEY}" "UninstallString"
|
||||
${IfThen} $UpdateMode = 1 ${|} StrCpy $R1 "$R1 /UPDATE" ${|} ; append /UPDATE
|
||||
${IfThen} $KeepAutoLaunch = 1 ${|} StrCpy $R1 "$R1 /KEEPAUTOLAUNCH" ${|}
|
||||
${IfThen} $PassiveMode = 1 ${|} StrCpy $R1 "$R1 /P" ${|} ; append /P
|
||||
StrCpy $R1 "$R1 _?=$4" ; append uninstall directory
|
||||
ExecWait '$R1' $0
|
||||
@@ -1098,6 +1103,11 @@ Function un.onInit
|
||||
${IfNot} ${Errors}
|
||||
StrCpy $UpdateMode 1
|
||||
${EndIf}
|
||||
|
||||
${GetOptions} $CMDLINE "/KEEPAUTOLAUNCH" $KeepAutoLaunch
|
||||
${IfNot} ${Errors}
|
||||
StrCpy $KeepAutoLaunch 1
|
||||
${EndIf}
|
||||
FunctionEnd
|
||||
|
||||
Section Uninstall
|
||||
@@ -1291,6 +1301,24 @@ Section Uninstall
|
||||
DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${PRODUCTNAME}"
|
||||
${EndIf}
|
||||
|
||||
${If} $UpdateMode <> 1
|
||||
${AndIf} $KeepAutoLaunch <> 1
|
||||
; UAC can run the uninstaller under a different account from the desktop user.
|
||||
StrCpy $R0 0
|
||||
${Do}
|
||||
EnumRegKey $R1 HKU "" $R0
|
||||
${If} $R1 == ""
|
||||
${ExitDo}
|
||||
${EndIf}
|
||||
StrCpy $R3 "$R1\Software\Microsoft\Windows\CurrentVersion\Run"
|
||||
ReadRegStr $R2 HKU "$R3" "Clash Verge Auto Launch"
|
||||
${If} $R2 == "$\"$INSTDIR\${MAINBINARYNAME}.exe$\""
|
||||
DeleteRegValue HKU "$R3" "Clash Verge Auto Launch"
|
||||
${EndIf}
|
||||
IntOp $R0 $R0 + 1
|
||||
${Loop}
|
||||
${EndIf}
|
||||
|
||||
; Delete app data if the checkbox is selected
|
||||
; and if not updating
|
||||
${If} $DeleteAppDataCheckboxState = 1
|
||||
|
||||
Reference in New Issue
Block a user