Update StackMonkey.ps1

This commit is contained in:
2025-10-16 19:51:50 -04:00
parent 813bf98d0d
commit a05f4e742a

View File

@@ -1855,28 +1855,28 @@ function Install-DattoRMM {
#> #>
'UI' { 'UI' {
$url = "http://localhost:$Port/" $url = "http://localhost:$Port/"
Write-LogHybrid "Starting ScriptMonkey UI on $url" Info Startup 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 = @( $edgeCandidates = @(
"${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe", "${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) { if (-not $edgePath) {
$cmd = Get-Command -Name 'msedge.exe' -ErrorAction SilentlyContinue $cmd = Get-Command -Name 'msedge.exe' -ErrorAction SilentlyContinue
if ($cmd) { $edgePath = $cmd.Path } 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 { Start-Job -Name 'OpenScriptMonkeyUI' -ScriptBlock {
param($u, $edge) param([string]$u, [string]$edge)
Start-Sleep -Milliseconds 400 Start-Sleep -Milliseconds 400
try { try {
if ($edge -and (Test-Path $edge)) { 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 { } else {
Start-Process -FilePath $u # fallback to default browser Start-Process -FilePath $u # fallback to default browser
} }
@@ -1886,6 +1886,8 @@ function Install-DattoRMM {
# Now start the blocking listener loop # Now start the blocking listener loop
Start-Server Start-Server
return return
}
} }