<# launch.ps1 - Launch TinyNotepad (MyNotepad.exe) Starts the GUI desktop application and writes ONLY its numeric PID to stdout as the first line. This script is standalone and does not depend on build.ps1 having been run in the same session, but the application must already be built into the install directory. TinyNotepad is a plain .NET Framework WinForms app - no sandbox flags or user-data-dir needed. #> $ErrorActionPreference = 'Stop' $InstallDir = (Join-Path (Split-Path $PSScriptRoot -Parent) 'install') $exe = Join-Path $InstallDir 'MyNotepad.exe' if (-not (Test-Path $exe)) { throw "Executable not found: $exe. Run build.ps1 first." } $proc = Start-Process -FilePath $exe -WorkingDirectory $InstallDir -PassThru Write-Output $proc.Id # Emit a trailing blank line so that callers capturing stdout with # $out = & powershell -File launch.ps1 # receive a string[] (one element per line) rather than a single [string]. # With a lone line, $out is a [string] and $out[0] would be the first # CHARACTER of the PID instead of the PID. The PID stays on the first line. Write-Output ""