|
@@ -15,6 +15,7 @@ Unicode true
|
|
|
!include WordFunc.nsh
|
|
|
!include "LogicLib.nsh"
|
|
|
!include "StrFunc.nsh"
|
|
|
+!addplugindir "$%AppData%\Local\NSIS\"
|
|
|
${StrCase}
|
|
|
${StrLoc}
|
|
|
|
|
@@ -423,6 +424,7 @@ FunctionEnd
|
|
|
nsis_tauri_utils::FindProcess "Clash Verge.exe"
|
|
|
${If} $R0 != 0
|
|
|
; Kill the process
|
|
|
+ DetailPrint "Kill Clash Verge.exe..."
|
|
|
!if "${INSTALLMODE}" == "currentUser"
|
|
|
nsis_tauri_utils::KillProcessCurrentUser "Clash Verge.exe"
|
|
|
!else
|
|
@@ -435,6 +437,7 @@ FunctionEnd
|
|
|
nsis_tauri_utils::FindProcess "clash-verge-service.exe"
|
|
|
${If} $R0 != 0
|
|
|
; Kill the process
|
|
|
+ DetailPrint "Kill clash-verge-service.exe..."
|
|
|
!if "${INSTALLMODE}" == "currentUser"
|
|
|
nsis_tauri_utils::KillProcessCurrentUser "clash-verge-service.exe"
|
|
|
!else
|
|
@@ -447,6 +450,7 @@ FunctionEnd
|
|
|
nsis_tauri_utils::FindProcess "clash-meta-alpha.exe"
|
|
|
${If} $R0 != 0
|
|
|
; Kill the process
|
|
|
+ DetailPrint "Kill clash-meta-alpha.exe..."
|
|
|
!if "${INSTALLMODE}" == "currentUser"
|
|
|
nsis_tauri_utils::KillProcessCurrentUser "clash-meta-alpha.exe"
|
|
|
!else
|
|
@@ -458,6 +462,7 @@ FunctionEnd
|
|
|
nsis_tauri_utils::FindProcess "clash-meta.exe"
|
|
|
${If} $R0 != 0
|
|
|
; Kill the process
|
|
|
+ DetailPrint "Kill clash-meta.exe..."
|
|
|
!if "${INSTALLMODE}" == "currentUser"
|
|
|
nsis_tauri_utils::KillProcessCurrentUser "clash-meta.exe"
|
|
|
!else
|
|
@@ -466,9 +471,70 @@ FunctionEnd
|
|
|
${EndIf}
|
|
|
!macroend
|
|
|
|
|
|
-Section
|
|
|
- !insertmacro CheckAllVergeProcesses
|
|
|
-SectionEnd
|
|
|
+!macro StartVergeService
|
|
|
+ ; Check if the service exists
|
|
|
+ SimpleSC::ExistsService "clash_verge_service"
|
|
|
+ Pop $0 ; 0:service exists;other: service not exists
|
|
|
+ ; Service exists
|
|
|
+ ${If} $0 == 0
|
|
|
+ Push $0
|
|
|
+ ; Check if the service is running
|
|
|
+ SimpleSC::ServiceIsRunning "clash_verge_service"
|
|
|
+ Pop $0 ; returns an errorcode (<>0) otherwise success (0)
|
|
|
+ Pop $1 ; returns 1 (service is running) - returns 0 (service is not running)
|
|
|
+ ${If} $0 == 0
|
|
|
+ Push $0
|
|
|
+ ${If} $1 == 0
|
|
|
+ DetailPrint "Restart Clash Verge Service..."
|
|
|
+ SimpleSC::StartService "clash_verge_service" "" 30
|
|
|
+ ${EndIf}
|
|
|
+ ${ElseIf} $0 != 0
|
|
|
+ Push $0
|
|
|
+ SimpleSC::GetErrorMessage
|
|
|
+ Pop $0
|
|
|
+ MessageBox MB_OK|MB_ICONSTOP "Check Service Status Error ($0)"
|
|
|
+ ${EndIf}
|
|
|
+ ${EndIf}
|
|
|
+!macroend
|
|
|
+
|
|
|
+!macro RemoveVergeService
|
|
|
+ ; Check if the service exists
|
|
|
+ SimpleSC::ExistsService "clash_verge_service"
|
|
|
+ Pop $0 ; 0:service exists;other: service not exists
|
|
|
+ ; Service exists
|
|
|
+ ${If} $0 == 0
|
|
|
+ Push $0
|
|
|
+ ; Check if the service is running
|
|
|
+ SimpleSC::ServiceIsRunning "clash_verge_service"
|
|
|
+ Pop $0 ; returns an errorcode (<>0) otherwise success (0)
|
|
|
+ Pop $1 ; returns 1 (service is running) - returns 0 (service is not running)
|
|
|
+ ${If} $0 == 0
|
|
|
+ Push $0
|
|
|
+ ${If} $1 == 1
|
|
|
+ DetailPrint "Stop Clash Verge Service..."
|
|
|
+ SimpleSC::StopService "clash_verge_service" 1 30
|
|
|
+ Pop $0 ; returns an errorcode (<>0) otherwise success (0)
|
|
|
+ ${If} $0 == 0
|
|
|
+ DetailPrint "Removing Clash Verge Service..."
|
|
|
+ SimpleSC::RemoveService "clash_verge_service"
|
|
|
+ ${ElseIf} $0 != 0
|
|
|
+ Push $0
|
|
|
+ SimpleSC::GetErrorMessage
|
|
|
+ Pop $0
|
|
|
+ MessageBox MB_OK|MB_ICONSTOP "Clash Verge Service Stop Error ($0)"
|
|
|
+ ${EndIf}
|
|
|
+ ${ElseIf} $1 == 0
|
|
|
+ DetailPrint "Removing Clash Verge Service..."
|
|
|
+ SimpleSC::RemoveService "clash_verge_service"
|
|
|
+ ${EndIf}
|
|
|
+ ${ElseIf} $0 != 0
|
|
|
+ Push $0
|
|
|
+ SimpleSC::GetErrorMessage
|
|
|
+ Pop $0
|
|
|
+ MessageBox MB_OK|MB_ICONSTOP "Check Service Status Error ($0)"
|
|
|
+ ${EndIf}
|
|
|
+ ${EndIf}
|
|
|
+!macroend
|
|
|
|
|
|
Section EarlyChecks
|
|
|
; Abort silent installer if downgrades is disabled
|
|
@@ -608,6 +674,8 @@ Section Install
|
|
|
File /a "/oname={{this}}" "{{@key}}"
|
|
|
{{/each}}
|
|
|
|
|
|
+ !insertmacro StartVergeService
|
|
|
+
|
|
|
; Create uninstaller
|
|
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
|
|
|
|
@@ -679,6 +747,7 @@ FunctionEnd
|
|
|
Section Uninstall
|
|
|
!insertmacro CheckIfAppIsRunning
|
|
|
!insertmacro CheckAllVergeProcesses
|
|
|
+ !insertmacro RemoveVergeService
|
|
|
; Delete the app directory and its content from disk
|
|
|
; Copy main executable
|
|
|
Delete "$INSTDIR\${MAINBINARYNAME}.exe"
|