# Installs a Windows Scheduled Task that starts usher at logon and # restarts on failure. This is optional — in normal operation, LibreWolf # manages usher's lifecycle via Native Messaging. This task ensures # usher is available for pre-LibreWolf power monitoring. $ErrorActionPreference = "Stop" $taskName = "VestibuleUsher" $usherPath = Join-Path $env:LOCALAPPDATA "Vestibule\usher.exe" if (-not (Test-Path $usherPath)) { Write-Error "usher.exe not found at $usherPath" Write-Host " Run install-native-host.ps1 first" exit 1 } # Remove existing task if present (idempotent) $existing = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue if ($existing) { Unregister-ScheduledTask -TaskName $taskName -Confirm:$false Write-Host "removed existing task: $taskName" } $action = New-ScheduledTaskAction -Execute $usherPath $trigger = New-ScheduledTaskTrigger -AtLogOn $settings = New-ScheduledTaskSettingsSet ` -RestartCount 3 ` -RestartInterval (New-TimeSpan -Minutes 1) ` -AllowStartIfOnBatteries ` -DontStopIfGoingOnBatteries Register-ScheduledTask ` -TaskName $taskName ` -Action $action ` -Trigger $trigger ` -Settings $settings ` -Description "Vestibule usher — kiosk unlock helper + power monitor" ` -RunLevel Limited Write-Host "installed scheduled task: $taskName" Write-Host " starts at logon, restarts up to 3x on failure" Write-Host "" Write-Host "To start now: Start-ScheduledTask -TaskName $taskName" Write-Host "To check: Get-ScheduledTask -TaskName $taskName | Get-ScheduledTaskInfo" Write-Host "To view logs: Event Viewer > Windows Logs > Application"