From a05f4e742a9451468c0cb6a9920887cdcd83242e Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Thu, 16 Oct 2025 19:51:50 -0400 Subject: [PATCH] Update StackMonkey.ps1 --- StackMonkey.ps1 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index de2768d..6b1419b 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -1855,28 +1855,28 @@ function Install-DattoRMM { #> - 'UI' { + 'UI' { $url = "http://localhost:$Port/" Write-LogHybrid "Starting ScriptMonkey UI on $url" Info Startup - # Resolve Edge path explicitly (works in both 32/64-bit installs) + # Resolve Edge path explicitly (x86 first, then 64-bit, then PATH) $edgeCandidates = @( "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe", - "$env:ProgramFiles\Microsoft\Edge\Application\msedge.exe + "$env:ProgramFiles\Microsoft\Edge\Application\msedge.exe" ) - $edgePath = ($edgeCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1) + $edgePath = $edgeCandidates | Where-Object { $_ -and (Test-Path $_) } | Select-Object -First 1 if (-not $edgePath) { $cmd = Get-Command -Name 'msedge.exe' -ErrorAction SilentlyContinue if ($cmd) { $edgePath = $cmd.Path } } - - # Launch Edge (app mode) in a background job so Start-Server can block + + # Launch Edge (app mode) in a background job so Start-Server can block Start-Job -Name 'OpenScriptMonkeyUI' -ScriptBlock { - param($u, $edge) + param([string]$u, [string]$edge) Start-Sleep -Milliseconds 400 try { if ($edge -and (Test-Path $edge)) { - Start-Process -FilePath $edge -ArgumentList @('--new-window',"--app=$u") + Start-Process -FilePath $edge -ArgumentList @('--new-window', "--app=$u") } else { Start-Process -FilePath $u # fallback to default browser } @@ -1886,6 +1886,8 @@ function Install-DattoRMM { # Now start the blocking listener loop Start-Server return + } + }