Update StackMonkey.ps1

This commit is contained in:
2025-10-16 19:35:53 -04:00
parent ff0061bc47
commit 8ebfe2eb3e

View File

@@ -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