Skip to content

Commit 8a55073

Browse files
committed
fix: updater usa elevacion (RunAs) + log
1 parent 6c4ddbf commit 8a55073

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

app/ui/frames/settings/tabs/updates_tab.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ def _worker():
193193
pid = os.getpid()
194194
exe_path = str(Path(sys.executable).resolve())
195195
ps_path = tmp_dir / "apply_update.ps1"
196-
ps_script = f"""param([int]$Pid, [string]$Installer, [string]$ExePath)\n\n$ErrorActionPreference = 'Stop'\n\nwhile (Get-Process -Id $Pid -ErrorAction SilentlyContinue) {{ Start-Sleep -Milliseconds 250 }}\n\n$p = Start-Process -FilePath $Installer -ArgumentList '/VERYSILENT /SUPPRESSMSGBOXES /NORESTART' -Wait -PassThru\nif ($p.ExitCode -eq 0) {{ Start-Process -FilePath $ExePath }}\n"""
196+
log_path = tmp_dir / "update.log"
197+
ps_script = f"""param([int]$Pid, [string]$Installer, [string]$ExePath, [string]$LogPath)\n\n$ErrorActionPreference = 'Stop'\n\nfunction Log([string]$Msg) {{\n $ts = (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')\n \"$ts $Msg\" | Out-File -FilePath $LogPath -Encoding UTF8 -Append\n}}\n\nLog \"update: waiting pid=$Pid\"\nwhile (Get-Process -Id $Pid -ErrorAction SilentlyContinue) {{ Start-Sleep -Milliseconds 250 }}\n\ntry {{\n Log \"update: starting installer=$Installer\"\n # Inno Setup suele requerir elevacion para Program Files.\n $p = Start-Process -FilePath $Installer -ArgumentList '/SP- /VERYSILENT /SUPPRESSMSGBOXES /NORESTART' -Verb RunAs -Wait -PassThru\n Log \"update: installer exitcode=$($p.ExitCode)\"\n if ($p.ExitCode -eq 0) {{\n Log \"update: relaunch $ExePath\"\n Start-Process -FilePath $ExePath\n }} else {{\n Log \"update: install failed\"\n }}\n}} catch {{\n Log \"update: exception $($_.Exception.Message)\"\n}}\n"""
197198
ps_path.write_text(ps_script, encoding="utf-8")
198199

199200
creationflags = 0
@@ -214,6 +215,8 @@ def _worker():
214215
str(setup_path),
215216
"-ExePath",
216217
exe_path,
218+
"-LogPath",
219+
str(log_path),
217220
],
218221
cwd=str(tmp_dir),
219222
creationflags=creationflags,

0 commit comments

Comments
 (0)