# Registers JournalBotService (runs ingest every 15 min). Run as Administrator. $ErrorActionPreference = "Stop" $root = Split-Path -Parent $PSScriptRoot $exe = Join-Path $root "tools\publish\Service\JournalBot.Service.exe" if (-not (Test-Path $exe)) { throw "Build first: scripts\build-tools.ps1" } $existing = Get-Service -Name "JournalBotService" -ErrorAction SilentlyContinue if ($existing) { sc.exe delete "JournalBotService" | Out-Null; Start-Sleep 2 } New-Service -Name "JournalBotService" -BinaryPathName "`"$exe`"" ` -DisplayName "JournalBot Ingest Service" -StartupType Automatic ` -Description "Polls Telegram every 15 minutes and queues journal items." Start-Service "JournalBotService" Write-Host "Service 'JournalBotService' installed and started."