geenforce display dispatcher: wait for kiosk URL before launching Edge

At auto-login the Startup shortcut fired before the network was up, so Edge
--kiosk navigated to nothing and sat on a blank white page with no retry.
Point the shortcut at a hidden VBS launcher (wscript, no console flash) that
polls the kiosk URL until it responds (up to ~3 min) and only then launches
Edge fullscreen, so the first paint is the real page. Falls through to launch
anyway after the timeout so a display is never left dark.
This commit is contained in:
cproudlock
2026-07-30 15:33:49 -04:00
parent ea6fae91c3
commit 95df51fddf

View File

@@ -218,16 +218,54 @@ try {{
ForEach-Object {{ Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue; Write-Host "killed old-URL kiosk Edge pid $($_.ProcessId)" }}
}} catch {{}}
$edgeArgs = "--kiosk `"$kioskUrl`" --edge-kiosk-type=fullscreen"
# WHY a launcher, not a direct Edge shortcut: at auto-login the shortcut fires
# before the network is up, so Edge --kiosk navigates to nothing and sits on a
# blank WHITE page with no retry. This VBS waits (hidden, no console flash -
# wscript has no window) until the kiosk URL actually responds, THEN launches
# Edge fullscreen, so the first paint is the real page. Gives up after ~3 min
# and launches anyway so a display is never left dark.
$launcherDir = Join-Path $env:ProgramData 'ShopDB'
if (-not (Test-Path $launcherDir)) {{ New-Item -ItemType Directory -Path $launcherDir -Force | Out-Null }}
$launcherPath = Join-Path $launcherDir 'Start-ShopdbKiosk.vbs'
$vbsTemplate = @'
Option Explicit
Dim kioskUrl, edgePath, i, reachable, http, shell
kioskUrl = "__URL__"
edgePath = "__EDGE__"
reachable = False
For i = 1 To 60
On Error Resume Next
Set http = CreateObject("MSXML2.ServerXMLHTTP.6.0")
http.SetTimeouts 5000, 5000, 5000, 5000
http.Open "GET", kioskUrl, False
http.Send
If Err.Number = 0 Then
If http.Status >= 200 And http.Status < 400 Then reachable = True
End If
On Error GoTo 0
If reachable Then Exit For
WScript.Sleep 3000
Next
Set shell = CreateObject("WScript.Shell")
Dim q
q = Chr(34)
shell.Run q & edgePath & q & " --kiosk " & q & kioskUrl & q & " --edge-kiosk-type=fullscreen", 1, False
'@
$vbs = $vbsTemplate.Replace('__URL__', $kioskUrl).Replace('__EDGE__', $edge)
Set-Content -LiteralPath $launcherPath -Value $vbs -Encoding ASCII
# Startup shortcut launches the VBS via wscript (windowless), which waits then
# opens Edge. TargetPath is wscript, not Edge, so the connectivity wait runs.
$wscript = Join-Path $env:WINDIR 'System32\\wscript.exe'
$lnkPath = Join-Path $startup 'ShopDB Kiosk.lnk'
$lnk = $shell.CreateShortcut($lnkPath)
$lnk.TargetPath = $edge
$lnk.Arguments = $edgeArgs
$lnk.WorkingDirectory = Split-Path -Parent $edge
$lnk.WindowStyle = 3
$lnk.TargetPath = $wscript
$lnk.Arguments = '"' + $launcherPath + '"'
$lnk.WorkingDirectory = $launcherDir
$lnk.WindowStyle = 7
$lnk.Description = "ShopDB kiosk display: $kioskUrl"
$lnk.Save()
Write-Host "display-type '$displayType' -> kiosk Startup shortcut for $kioskUrl"
Write-Host "display-type '$displayType' -> kiosk Startup launcher (waits for $kioskUrl)"
"""