# Quick Update - Make Existing Periodic Save Task Invisible # This script updates the existing task to run without showing a window $TaskName = "ClaudeTools - Periodic Context Save" Write-Host "Updating task '$TaskName' to run invisibly..." Write-Host "" # Check if task exists $Task = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue if (-not $Task) { Write-Host "ERROR: Task '$TaskName' not found." Write-Host "Run setup_periodic_save.ps1 to create it first." exit 1 } # Find pythonw.exe path $PythonExe = (Get-Command python).Source $PythonDir = Split-Path $PythonExe -Parent $PythonwPath = Join-Path $PythonDir "pythonw.exe" if (-not (Test-Path $PythonwPath)) { Write-Host "ERROR: pythonw.exe not found at $PythonwPath" Write-Host "Please reinstall Python to get pythonw.exe" exit 1 } Write-Host "Found pythonw.exe at: $PythonwPath" # Update the action to use pythonw.exe $NewAction = New-ScheduledTaskAction -Execute $PythonwPath ` -Argument "D:\ClaudeTools\.claude\hooks\periodic_save_check.py" ` -WorkingDirectory "D:\ClaudeTools" # Update settings to be hidden $NewSettings = New-ScheduledTaskSettingsSet ` -AllowStartIfOnBatteries ` -DontStopIfGoingOnBatteries ` -StartWhenAvailable ` -ExecutionTimeLimit (New-TimeSpan -Minutes 5) ` -Hidden # Update principal to run in background (S4U = Service-For-User) $NewPrincipal = New-ScheduledTaskPrincipal -UserId "$env:USERDOMAIN\$env:USERNAME" -LogonType S4U # Get existing trigger (preserve it) $ExistingTrigger = $Task.Triggers # Update the task Set-ScheduledTask -TaskName $TaskName ` -Action $NewAction ` -Settings $NewSettings ` -Principal $NewPrincipal ` -Trigger $ExistingTrigger | Out-Null Write-Host "" Write-Host "[SUCCESS] Task updated successfully!" Write-Host "" Write-Host "Changes made:" Write-Host " 1. Changed executable: python.exe -> pythonw.exe" Write-Host " 2. Set task to Hidden" Write-Host " 3. Changed LogonType: Interactive -> S4U (background)" Write-Host "" Write-Host "Verification:" # Show current settings $UpdatedTask = Get-ScheduledTask -TaskName $TaskName $Settings = $UpdatedTask.Settings $Action = $UpdatedTask.Actions[0] $Principal = $UpdatedTask.Principal Write-Host " Executable: $($Action.Execute)" Write-Host " Hidden: $($Settings.Hidden)" Write-Host " LogonType: $($Principal.LogonType)" Write-Host "" if ($Settings.Hidden -and $Action.Execute -like "*pythonw.exe" -and $Principal.LogonType -eq "S4U") { Write-Host "[OK] All settings correct - task will run invisibly!" } else { Write-Host "[WARNING] Some settings may not be correct - please verify manually" } Write-Host "" Write-Host "The task will now run invisibly without showing any console window." Write-Host ""