Update StackMonkey.ps1
This commit is contained in:
@@ -1826,22 +1826,6 @@ function Install-DattoRMM {
|
||||
}
|
||||
|
||||
<#
|
||||
'UI' {
|
||||
Write-LogHybrid "Starting ScriptMonkey UI on http://localhost:$Port/" Info Startup
|
||||
try {
|
||||
Start-Server
|
||||
try {
|
||||
Start-Process "msedge.exe" -ArgumentList "--app=http://localhost:$Port" -ErrorAction Stop
|
||||
} catch {
|
||||
Start-Process "http://localhost:$Port"
|
||||
}
|
||||
} catch {
|
||||
Write-LogHybrid "Failed to start server: $($_.Exception.Message)" Error Startup -LogToEvent
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
#>
|
||||
|
||||
'UI' {
|
||||
$url = "http://localhost:$Port/"
|
||||
@@ -1869,6 +1853,41 @@ function Install-DattoRMM {
|
||||
return
|
||||
}
|
||||
|
||||
#>
|
||||
|
||||
'UI' {
|
||||
$url = "http://localhost:$Port/"
|
||||
Write-LogHybrid "Starting ScriptMonkey UI on $url" Info Startup
|
||||
|
||||
# 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"
|
||||
)
|
||||
$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 {
|
||||
try {
|
||||
if (Get-Command -Name $using:edgePath -ErrorAction SilentlyContinue) {
|
||||
Start-Process -FilePath $using:edgePath -ArgumentList @('--new-window', "--app=$using:url")
|
||||
} else {
|
||||
Start-Process -FilePath $using:url
|
||||
}
|
||||
} catch {
|
||||
# no-op
|
||||
}
|
||||
} | Out-Null
|
||||
$timer.Start()
|
||||
|
||||
# Now start the blocking listener loop
|
||||
Start-Server
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user