Files
GerbilManager/deploy/scripts/Register-AutoStart.ps1
Gulum dada3af968 OPS-1: startup scripts, autostart task, backup task, ops README, production config
- appsettings.Production.json: Photos:RootPath -> C:\gerbil-data\photos so
  photo files land on a stable host path when ASPNETCORE_ENVIRONMENT=Production
- Start-GerbilManager.ps1: creates data dirs, sets Production env, launches
  AppHost minimised; saves PID for Stop script
- Stop-GerbilManager.ps1: kills AppHost + Vite node processes by PID / port
- Register-AutoStart.ps1: Windows Scheduled Task on user logon (RunLevel Highest)
- Register-BackupTask.ps1: daily 03:00 Scheduled Task for Backup script
- deploy/README.md: Julian ops guide — start/stop commands, phone URL, DHCP
  reservation, firewall rule (Public-profile Wi-Fi), backup/restore procedures,
  prerequisites checklist, troubleshooting table (German)

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
2026-06-06 07:11:09 +02:00

64 lines
2.1 KiB
PowerShell

<#
.SYNOPSIS
Registriert GerbilManager als Windows-Autostart (geplante Aufgabe bei Benutzeranmeldung).
.DESCRIPTION
Erstellt eine geplante Aufgabe, die Start-GerbilManager.ps1 automatisch startet,
wenn sich der aktuelle Benutzer anmeldet. Erfordert Administratorrechte.
.NOTES
Erfordert: PowerShell als Administrator ausfuehren
Aufgabenname: GerbilManager AutoStart
#>
#Requires -RunAsAdministrator
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$taskName = "GerbilManager AutoStart"
$scriptPath = Join-Path $PSScriptRoot "Start-GerbilManager.ps1"
$projectRoot = Resolve-Path (Join-Path $PSScriptRoot "..\..")
if (-not (Test-Path $scriptPath)) {
Write-Error "Startskript nicht gefunden: $scriptPath"
exit 1
}
Write-Host "Registriere geplante Aufgabe '$taskName'..."
$action = New-ScheduledTaskAction `
-Execute "powershell.exe" `
-Argument "-NonInteractive -WindowStyle Hidden -ExecutionPolicy Bypass -File `"$scriptPath`"" `
-WorkingDirectory $projectRoot
$trigger = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME
$settings = New-ScheduledTaskSettingsSet `
-ExecutionTimeLimit (New-TimeSpan -Hours 0) `
-RestartCount 3 `
-RestartInterval (New-TimeSpan -Minutes 2) `
-StartWhenAvailable `
-MultipleInstances IgnoreNew
$principal = New-ScheduledTaskPrincipal `
-UserId $env:USERNAME `
-LogonType Interactive `
-RunLevel Highest
# Vorhandene Aufgabe entfernen, falls noetig
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction SilentlyContinue
Register-ScheduledTask `
-TaskName $taskName `
-Action $action `
-Trigger $trigger `
-Settings $settings `
-Principal $principal `
-Description "Startet GerbilManager (Rennmaus-Verwaltung) automatisch bei der Benutzeranmeldung." `
-Force | Out-Null
Write-Host "Aufgabe registriert: '$taskName'"
Write-Host "GerbilManager startet ab sofort automatisch beim Anmelden."
Write-Host ""
Write-Host "Aufgabe pruefen : Get-ScheduledTask -TaskName '$taskName'"
Write-Host "Aufgabe entfernen: Unregister-ScheduledTask -TaskName '$taskName' -Confirm:`$false"