Private/Start-WPFApplication.ps1
|
# Private helper function for WPF application startup # This function provides additional startup logic if needed in the future function Start-WPFApplication { <# .SYNOPSIS Internal helper for starting the WPF application. .DESCRIPTION This private function provides a centralized location for WPF application startup logic, pre-flight checks, and initialization tasks. .PARAMETER ExePath Path to the WPF executable. .PARAMETER Arguments Arguments to pass to the WPF application. #> [CmdletBinding()] param( [Parameter(Mandatory)] [string]$ExePath, [Parameter()] [string[]]$Arguments ) # Verify .NET Desktop Runtime prerequisites try { $dotnetInfo = & dotnet --list-runtimes 2>$null | Where-Object { $_ -match 'Microsoft\.WindowsDesktop\.App' } if (-not $dotnetInfo) { Write-Warning @" .NET Desktop Runtime not detected. The GUI may not run correctly. To install .NET Desktop Runtime 8.0, visit: https://dotnet.microsoft.com/download/dotnet/8.0 "@ } else { Write-Verbose ".NET Desktop Runtime detected: $($dotnetInfo -join ', ')" } } catch { Write-Verbose "Could not verify .NET runtime installation" } # Launch the application if ($Arguments) { & $ExePath $Arguments } else { & $ExePath } } |