Files
obsidian-notes/.omx/setup-task.ps1
2026-05-07 01:13:24 +08:00

26 lines
1.1 KiB
PowerShell

# setup-task.ps1
# Register the nightly InBox→Gantt sync task in Windows Task Scheduler.
# Run once, as Administrator.
$taskName = "InBox-Gantt-Nightly-Sync"
$scriptPath = "C:\Users\Zane\Desktop\Gantt-App\sync-inbox-to-gantt.ps1"
# Remove existing task if present
$existing = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
if ($existing) {
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false
Write-Host "Removed existing task: $taskName"
}
$action = New-ScheduledTaskAction -Execute "powershell.exe" `
-Argument "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$scriptPath`""
$trigger = New-ScheduledTaskTrigger -Daily -At 22:30
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable
Register-ScheduledTask -TaskName $taskName `
-Action $action -Trigger $trigger -Settings $settings `
-Description "Nightly: git sync PARA/InBox + mirror InBox .md files to Gantt '待看:*' tasks"
Write-Host "Task '$taskName' registered. Next run: $(Get-Date -Format 'yyyy-MM-dd') 22:30"
Write-Host "Script: $scriptPath"