Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
test(windows): verify real NSIS silent uninstall after native installed acceptance
davoodmehraban89 committed
Oct 17, 2026 at 00:21 UTC
dfa4a14191c82802c57d45bb4b2f43a2ef500324
1 file changed
+41
scripts/windows-vm-treasury-uninstall-smoke.ps1
new
+41
@@ -0,0 +1,41 @@
1
+param([Parameter(Mandatory=$true)][string]$InstalledFolder)
2
+$ErrorActionPreference='Stop'
3
+$evidence=Join-Path $env:RUNNER_TEMP 'treasuryflow-vm-evidence'
4
+New-Item -ItemType Directory -Path $evidence -Force | Out-Null
5
+$report=[ordered]@{
6
+ schema='treasuryflow-windows-nsis-uninstall-v1'
7
+ mode='ACTUAL_INSTALLED_NSIS_UNINSTALL'
8
+ installerRootFound=$false
9
+ uninstallerFound=$false
10
+ uninstallerExitCode=$null
11
+ executableRemoved=$false
12
+ outcome='NOT_RUN'
13
+}
14
+try{
15
+ if(!(Test-Path -LiteralPath $InstalledFolder)){throw 'INSTALLED_FOLDER_MISSING'}
16
+ $report.installerRootFound=$true
17
+ $apps=@(Get-ChildItem -LiteralPath $InstalledFolder -Recurse -File -Filter 'TreasuryFlow.exe' -ErrorAction SilentlyContinue)
18
+ if($apps.Count -ne 1){throw 'INSTALLED_EXE_NOT_UNIQUE'}
19
+ $uninstallers=@(Get-ChildItem -LiteralPath $InstalledFolder -Recurse -File -ErrorAction SilentlyContinue |
20
+ Where-Object {$_.Name -match '^uninstall.*\.exe$'})
21
+ if($uninstallers.Count -ne 1){throw 'NSIS_UNINSTALLER_NOT_UNIQUE'}
22
+ $report.uninstallerFound=$true
23
+ $process=Start-Process -FilePath $uninstallers[0].FullName -ArgumentList '/S' -PassThru
24
+ if(!$process.WaitForExit(90000)){
25
+ try{$process.Kill()}catch{}
26
+ throw 'NSIS_UNINSTALL_TIMEOUT'
27
+ }
28
+ $report.uninstallerExitCode=$process.ExitCode
29
+ 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'}
33
+ $report.outcome='NSIS_REAL_UNINSTALL_PASS'
34
+ 'Uninstalled real disposable TreasuryFlow NSIS installation with /S and verified EXE removal.' >> $env:GITHUB_STEP_SUMMARY
35
+}catch{
36
+ $report.outcome='FAILED'
37
+ $report.failureCode=$_.Exception.Message
38
+ throw
39
+}finally{
40
+ $report | ConvertTo-Json -Depth 4 | Set-Content (Join-Path $evidence 'uninstall-runtime.json') -Encoding UTF8
41
+}