Setup-SynologyDriveUpdate.bat hinzugefügt
This commit is contained in:
commit
10784f6c0b
1 file changed
+32
@@ -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
|
||||||
Reference in new issue
Block a user