Files
media-player-server/scripts/install_task_windows.ps1
alexei.dolgolyov c5f8c7a092 Fix HTTPException handling in folder endpoints and install script path
- Add missing `except HTTPException: raise` in create_folder and
  update_folder endpoints to prevent 400 errors being masked as 500s
- Fix install_task_windows.ps1 working directory to point to
  media-server root instead of parent project root

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 13:09:47 +03:00

20 lines
1.0 KiB
PowerShell

Unregister-ScheduledTask -TaskName "MediaServer" -Confirm:$false -ErrorAction SilentlyContinue
# Get the media-server directory (parent of scripts folder)
$serverRoot = (Get-Item $PSScriptRoot).Parent.FullName
# Find Python executable
$pythonPath = (Get-Command python -ErrorAction SilentlyContinue).Source
if (-not $pythonPath) {
Write-Error "Python not found in PATH. Please ensure Python is installed and accessible."
exit 1
}
$action = New-ScheduledTaskAction -Execute $pythonPath -Argument "-m media_server.main" -WorkingDirectory $serverRoot
$trigger = New-ScheduledTaskTrigger -AtStartup
$principal = New-ScheduledTaskPrincipal -UserId "$env:USERNAME" -LogonType S4U -RunLevel Highest
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable
Register-ScheduledTask -TaskName "MediaServer" -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Description "Media Server for Home Assistant"
Write-Host "Scheduled task 'MediaServer' created with working directory: $serverRoot"