#Requires -Version 5.1 <# launch.ps1 - Launches Bounding Box Editor and prints its PID to stdout. The application is a self-contained jpackage app-image: BoundingBoxEditor.exe is a native launcher that starts a bundled JRE and the JavaFX GUI. It needs no external Java runtime and no special environment. Contract required by the pipeline: - The numeric PID is the FIRST line of stdout (via Write-Output). - No Write-Host, no text before the PID. Note: a trailing blank line is emitted after the PID on purpose. When the pipeline captures this script's output with `$out = & powershell -File ...`, PowerShell returns a *scalar string* if only one line is printed, so `$out[0]` would index the first CHARACTER of the PID rather than the PID. Emitting a second line forces the capture to be a string[] array, so `[int]$out[0]` correctly yields the full PID. #> $ErrorActionPreference = 'Stop' $InstallDir = (Join-Path (Split-Path $PSScriptRoot -Parent) 'install') $Exe = Join-Path $InstallDir 'BoundingBoxEditor.exe' # Start the native launcher from its own directory. The app reads its JVM # options from app\BoundingBoxEditor.cfg, so no extra flags are needed. $proc = Start-Process -FilePath $Exe -WorkingDirectory $InstallDir -PassThru Write-Output $proc.Id Write-Output ""