From 8ebfe2eb3ef0d954d26f30bcc8c095fb52a08f7f Mon Sep 17 00:00:00 2001 From: Stephan Yelle Date: Thu, 16 Oct 2025 19:35:53 -0400 Subject: [PATCH] Update StackMonkey.ps1 --- StackMonkey.ps1 | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index 510a90d..250d2ed 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -1825,7 +1825,7 @@ function Install-DattoRMM { } - +<# 'UI' { Write-LogHybrid "Starting ScriptMonkey UI on http://localhost:$Port/" Info Startup try { @@ -1841,7 +1841,35 @@ function Install-DattoRMM { return } - + #> + + 'UI' { + $url = "http://localhost:$Port/" + Write-LogHybrid "Starting ScriptMonkey UI on $url" Info Startup + + # Open the UI in a separate PowerShell job so Start-Server can block safely. + try { + Start-Job -Name 'OpenScriptMonkeyUI' -ScriptBlock { + param($u) + Start-Sleep -Milliseconds 300 + try { + if (Get-Command -Name 'msedge.exe' -ErrorAction SilentlyContinue) { + Start-Process -FilePath 'msedge.exe' -ArgumentList "--app=$u" + } else { + Start-Process -FilePath $u + } + } catch { } + } -ArgumentList $url | Out-Null + } catch { + Write-LogHybrid "Failed to schedule browser launch: $($_.Exception.Message)" Warning Startup -LogToEvent + } + + # Now start the blocking listener loop + Start-Server + return + } + + } #endregion EntryPoint: Define Invoke-ScriptMonkey