# --- Configuration --- $ProcessName = "E:\project\unity\CryEngineToolForDev\x64\Release\CryEngineTool.exe" # Replace with your executable $Arguments = "test.txt" # Replace with your arguments $WarningTimeoutSec = 20 # 10 minutes $KillTimeoutSec = 30 # 15 minutes # Start the process $proc = Start-Process -FilePath $ProcessName -ArgumentList $Arguments -PassThru Write-Host "Process started with ID: $($proc.Id). Monitoring..." -ForegroundColor Cyan # Monitor loop $StartTime = Get-Date $WarningSent = $false while (-not $proc.HasExited) { $Elapsed = (Get-Date) - $StartTime # 10 Minute Warning if ($Elapsed.TotalSeconds -ge $WarningTimeoutSec -and -not $WarningSent) { Write-Warning "Process has been running for over 10 minutes!" $WarningSent = $true } # 15 Minute Kill if ($Elapsed.TotalSeconds -ge $KillTimeoutSec) { Write-Host "Process exceeded 15 minutes. Terminating..." -ForegroundColor Red Stop-Process -Id $proc.Id -Force break } # Sleep briefly to save CPU cycles Start-Sleep -Seconds 5 } # Final Status if ($proc.HasExited) { Write-Host "Process exited with code: $($proc.ExitCode)" -ForegroundColor Green } else { Write-Host "Process was killed by script." -ForegroundColor Yellow }