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