Setup-SynologyDriveUpdate.bat aktualisiert
This commit is contained in:
1 parent
24fb3bb640
commit
c91c5d5527
1 file changed
+13
-3
@@ -10,17 +10,27 @@ if %errorlevel% neq 0 (
|
||||
exit /b
|
||||
)
|
||||
|
||||
echo Richte Aufgabenplanung (Scheduled Task) als SYSTEM ein...
|
||||
echo.
|
||||
echo ===================================================
|
||||
echo Synology Drive - Auto-Updater Einrichtung
|
||||
echo ===================================================
|
||||
echo.
|
||||
echo Richte Aufgabenplanung (Scheduled Task) im User-Kontext 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%"
|
||||
|
||||
:: HIER DIE AENDERUNG:
|
||||
:: Statt 'SYSTEM' nutzen wir die SID der lokalen Administratoren-Gruppe (S-1-5-32-544)
|
||||
:: Das verhindert Sprachprobleme (Administrators vs Administratoren) und nutzt den User-Kontext inkl. Winget!
|
||||
echo $Principal = New-ScheduledTaskPrincipal -GroupId 'S-1-5-32-544' -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%"
|
||||
echo Write-Host '[OK] Task "SynologyDrive_AutoUpdate" erfolgreich im Admin-User-Kontext angelegt!' -ForegroundColor Green >> "%ps_script%"
|
||||
|
||||
:: 3. PowerShell-Script ausfuehren
|
||||
powershell -NoProfile -ExecutionPolicy Bypass -File "%ps_script%"
|
||||
|
||||
Reference in new issue
Block a user