$ErrorActionPreference = 'Stop' $dir = 'D:\ROA\ROAFACTURARE\COMUN\utile\Teste\facturare_unificat' $prg = Join-Path $dir 'test_s6_3b_v2_primul.prg' $log = Join-Path $dir 'out\test_s6_3b_v2_primul.log' $vfp = 'C:\Program Files (x86)\Microsoft Visual FoxPro 9\vfp9.exe' $viu = Get-WmiObject Win32_Process -Filter "Name='vfp9.exe'" | Where-Object { $_.CommandLine -like '*test_s6_3b_v2_primul*' } if ($viu) { "Ruleaza deja o instanta a suitei (PID " + ($viu.ProcessId -join ',') + "). Nu lansez a doua." exit 1 } Set-Location $dir Remove-Item (Join-Path $dir 'test_s6_3b_v2_primul.FXP') -ErrorAction SilentlyContinue Remove-Item $log -ErrorAction SilentlyContinue $p = Start-Process -FilePath $vfp -ArgumentList '-A', '-T', $prg -PassThru "lansat PID " + $p.Id $null = $p.WaitForExit(300000) if (-not $p.HasExited) { "ATARNAT dupa 300s - omor instanta (filtrat pe CommandLine)" Get-WmiObject Win32_Process -Filter "Name='vfp9.exe'" | Where-Object { $_.CommandLine -like '*test_s6_3b_v2_primul*' } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force } } if (Test-Path $log) { Get-Content $log } else { "Log inexistent: $log" }