+ 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"""
0 commit comments