Treasury & Bank Transfer Management System — سامانه مدیریت خزانه‌داری و حواله‌های بانکی

fix(windows): stop installed Electron and wait boundedly for real NSIS uninstall file removal

davoodmehraban89 committed Oct 17, 2026 at 02:13 UTC d02a5c92ac622c756bdf798d6402c829ff7f189e
1 file changed +15 -3
scripts/windows-vm-treasury-uninstall-smoke.ps1
+15 -3
@@ -8,6 +8,8 @@ $report=[ordered]@{
8 installerRootFound=$false
9 uninstallerFound=$false
10 uninstallerExitCode=$null
11 + remainingDesktopProcessesStopped=0
12 + removalWaitSeconds=0
13 executableRemoved=$false
14 outcome='NOT_RUN'
15 }
@@ -20,6 +22,12 @@ try{
22 Where-Object {$_.Name -match '^uninstall.*\.exe$'})
23 if($uninstallers.Count -ne 1){throw 'NSIS_UNINSTALLER_NOT_UNIQUE'}
24 $report.uninstallerFound=$true
25 + # Dispose of the synthetic installed app first; Windows holds running EXEs open.
26 + $running=@(Get-Process -Name 'TreasuryFlow' -ErrorAction SilentlyContinue)
27 + foreach($instance in $running){
28 + try{Stop-Process -Id $instance.Id -Force -ErrorAction Stop;$report.remainingDesktopProcessesStopped++}catch{}
29 + }
30 + Start-Sleep -Milliseconds 800
31 $process=Start-Process -FilePath $uninstallers[0].FullName -ArgumentList '/S' -PassThru
32 if(!$process.WaitForExit(90000)){
33 try{$process.Kill()}catch{}
@@ -27,9 +35,13 @@ try{
35 }
36 $report.uninstallerExitCode=$process.ExitCode
37 if($process.ExitCode -ne 0){throw 'NSIS_UNINSTALL_NONZERO_EXIT'}
30 - Start-Sleep -Seconds 2
31 - $report.executableRemoved=!(Test-Path -LiteralPath $apps[0].FullName)
32 - if(!$report.executableRemoved){throw 'NSIS_UNINSTALL_LEFT_INSTALLED_EXE'}
38 + $startWait=[System.Diagnostics.Stopwatch]::StartNew()
39 + while($startWait.Elapsed.TotalSeconds -lt 90){
40 + if(!(Test-Path -LiteralPath $apps[0].FullName)){$report.executableRemoved=$true;break}
41 + Start-Sleep -Seconds 1
42 + }
43 + $report.removalWaitSeconds=[math]::Round($startWait.Elapsed.TotalSeconds,1)
44 + if(!$report.executableRemoved){throw 'NSIS_UNINSTALL_LEFT_INSTALLED_EXE_AFTER_90_SECONDS'}
45 $report.outcome='NSIS_REAL_UNINSTALL_PASS'
46 'Uninstalled real disposable TreasuryFlow NSIS installation with /S and verified EXE removal.' >> $env:GITHUB_STEP_SUMMARY
47 }catch{