Update StackMonkey.ps1

This commit is contained in:
2025-10-16 19:47:04 -04:00
parent 1eba4e05e8
commit 813bf98d0d

View File

@@ -1861,33 +1861,31 @@ function Install-DattoRMM {
# Resolve Edge path explicitly (works in both 32/64-bit installs)
$edgeCandidates = @(
"$env:ProgramFiles\Microsoft\Edge\Application\msedge.exe",
"${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe"
"${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe",
"$env:ProgramFiles\Microsoft\Edge\Application\msedge.exe
)
$edgePath = ($edgeCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1)
if (-not $edgePath) { $edgePath = 'msedge.exe' }
# Fire Edge in app mode shortly after, so the server is ready.
$timer = New-Object System.Timers.Timer
$timer.Interval = 400
$timer.AutoReset = $false
Register-ObjectEvent -InputObject $timer -EventName Elapsed -Action {
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
Start-Job -Name 'OpenScriptMonkeyUI' -ScriptBlock {
param($u, $edge)
Start-Sleep -Milliseconds 400
try {
if (Get-Command -Name $using:edgePath -ErrorAction SilentlyContinue) {
Start-Process -FilePath $using:edgePath -ArgumentList @('--new-window', "--app=$using:url")
if ($edge -and (Test-Path $edge)) {
Start-Process -FilePath $edge -ArgumentList @('--new-window',"--app=$u")
} else {
Start-Process -FilePath $using:url
Start-Process -FilePath $u # fallback to default browser
}
} catch {
# no-op
}
} | Out-Null
$timer.Start()
} catch { }
} -ArgumentList $url, $edgePath | Out-Null
# Now start the blocking listener loop
Start-Server
return
}
}