param([Parameter(Mandatory)][string]$Label,[switch]$Force)
$ErrorActionPreference='Stop'
if($Label -notmatch '^[a-zA-Z0-9-]+$'){throw 'Invalid evidence label.'}
$taskRoot=Split-Path -Parent $PSScriptRoot
$taskReport=Get-Content -LiteralPath (Join-Path $taskRoot ('artifacts\crash-analysis-20261021\startup-'+$Label+'.json')) -Raw | ConvertFrom-Json
$taskProcess=Get-Process -Id $taskReport.processId -ErrorAction SilentlyContinue
if(-not $taskProcess){return}
$taskGame='D:\SteamLibrary\steamapps\common\Elite Dangerous\Products\elite-dangerous-odyssey-64\EliteDangerous64.exe'
if($taskProcess.MainModule.FileName -ne $taskGame -or $taskProcess.StartTime -lt [datetime]$taskReport.startedAt -or $taskProcess.StartTime -gt [datetime]$taskReport.completedAt){throw 'The observed process identity changed.'}
if($Force){$taskProcess.Kill($false);$taskClosed=$false}else{$taskClosed=$taskProcess.CloseMainWindow()}
$taskExited=$taskProcess.WaitForExit(15000)
[ordered]@{processId=$taskProcess.Id;closeRequested=$taskClosed;forcedStop=$Force.IsPresent;exited=$taskExited} | ConvertTo-Json
if(-not $taskExited){throw 'The game did not close normally. No plugin update was performed.'}
param([Parameter(Mandatory)][string]$Label,[switch]$Force)
$ErrorActionPreference='Stop'
if($Label -notmatch '^[a-zA-Z0-9-]+$'){throw 'Invalid evidence label.'}
$taskRoot=Split-Path -Parent $PSScriptRoot
$taskReport=Get-Content -LiteralPath (Join-Path $taskRoot ('artifacts\crash-analysis-20261021\startup-'+$Label+'.json')) -Raw | ConvertFrom-Json
$taskProcess=Get-Process -Id $taskReport.processId -ErrorAction SilentlyContinue
if(-not $taskProcess){return}
$taskGame='D:\SteamLibrary\steamapps\common\Elite Dangerous\Products\elite-dangerous-odyssey-64\EliteDangerous64.exe'
if($taskProcess.MainModule.FileName -ne $taskGame -or $taskProcess.StartTime -lt [datetime]$taskReport.startedAt -or $taskProcess.StartTime -gt [datetime]$taskReport.completedAt){throw 'The observed process identity changed.'}
if($Force){$taskProcess.Kill($false);$taskClosed=$false}else{$taskClosed=$taskProcess.CloseMainWindow()}
$taskExited=$taskProcess.WaitForExit(15000)
[ordered]@{processId=$taskProcess.Id;closeRequested=$taskClosed;forcedStop=$Force.IsPresent;exited=$taskExited} | ConvertTo-Json
if(-not $taskExited){throw 'The game did not close normally. No plugin update was performed.'}