feat(client, server): enhance self-update process with fallback directory handling and UAC elevation for Windows

This commit is contained in:
Flik
2026-03-06 21:22:58 +08:00
parent ba9edd3c02
commit d6627a292d
2 changed files with 72 additions and 30 deletions

View File

@@ -165,6 +165,12 @@ func performSelfUpdate(downloadURL string, restart bool) error {
// performWindowsUpdate Windows 平台更新
func performWindowsUpdate(newFile, currentPath string, restart bool) error {
batchScript := fmt.Sprintf(`@echo off
:: Check for admin rights, request UAC elevation if needed
net session >nul 2>&1
if %%errorlevel%% neq 0 (
powershell -Command "Start-Process cmd -ArgumentList '/C \\"\"%%~f0\"\"' -Verb RunAs"
exit /b
)
ping 127.0.0.1 -n 2 > nul
del "%s"
move "%s" "%s"