From 10784f6c0beb56f45db505ff424c722bca37fcbd Mon Sep 17 00:00:00 2001 From: "manuel.maier" Date: Thu, 20 Aug 2026 16:37:44 +0200 Subject: [PATCH] =?UTF-8?q?Setup-SynologyDriveUpdate.bat=20hinzugef=C3=BCg?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Setup-SynologyDriveUpdate.bat | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Setup-SynologyDriveUpdate.bat diff --git a/Setup-SynologyDriveUpdate.bat b/Setup-SynologyDriveUpdate.bat new file mode 100644 index 0000000..1a0fb89 --- /dev/null +++ b/Setup-SynologyDriveUpdate.bat @@ -0,0 +1,32 @@ +@echo off +chcp 65001 >nul +TITLE Synology Drive Winget Auto-Updater Setup + +:: 1. Admin-Rechte pruefen und ggf. anfordern (Self-Elevation) +net session >nul 2>&1 +if %errorlevel% neq 0 ( + echo Administratorrechte fehlen. Starte neu mit erhoehten Rechten... + powershell -Command "Start-Process -FilePath '%~f0' -Verb RunAs" + exit /b +) + +echo Richte Aufgabenplanung (Scheduled Task) als SYSTEM ein... +set "ps_script=%temp%\setup_synology_task.ps1" + +:: 2. PowerShell-Logik in temporaere Datei schreiben +echo $TaskName = 'SynologyDrive_AutoUpdate' > "%ps_script%" +echo $Action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-WindowStyle Hidden -NoProfile -Command "Start-Process winget.exe -ArgumentList ''upgrade -e --id Synology.DriveClient --accept-package-agreements --accept-source-agreements --silent'' -WindowStyle Hidden -Wait"' >> "%ps_script%" +echo $Trigger = New-ScheduledTaskTrigger -AtLogon >> "%ps_script%" +echo $Principal = New-ScheduledTaskPrincipal -UserId 'SYSTEM' -LogonType ServiceAccount -RunLevel Highest >> "%ps_script%" +echo $Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -Hidden -StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Minutes 15) >> "%ps_script%" +echo Register-ScheduledTask -TaskName $TaskName -Action $Action -Trigger $Trigger -Principal $Principal -Settings $Settings -Force ^| Out-Null >> "%ps_script%" +echo Write-Host 'Task "SynologyDrive_AutoUpdate" erfolgreich angelegt!' -ForegroundColor Green >> "%ps_script%" + +:: 3. PowerShell-Script ausfuehren +powershell -NoProfile -ExecutionPolicy Bypass -File "%ps_script%" + +:: 4. Aufraeumen +del "%ps_script%" +echo. +echo Fertig! Das Fenster schliesst sich in 5 Sekunden... +timeout /t 5 >nul \ No newline at end of file