MUO logo

I automate these 5 essential tasks on every Windows installation and it keeps things running flawlessly

Automating tasks on Windows 11 with scripts and the Task Scheduler
Sign in to your MUO account

Windows 11 is a solid operating system, but it has some hidden inefficiencies. Background apps creep in, temp files pile up, and over time you'll experience subtle slowdowns that ruin productivity. You may deal with these reactively, waiting for the system to become slow before you clean it up. But with Task Scheduler or simple scripts, you can automate fixes or maintenance that keep your PC running smoothly.

There are a handful of automations I set up on every Windows machine. These aren't generic; they save you time, optimize performance, and protect your data. I recommend you adopt them as well to have an improved experience. While I use the native Task Scheduler, there are several other tools you can use for task automation on Windows.

Clean slate power-up

A fresh login that feels like a reboot

You can give your system a "mini-reset" with Task Scheduler every time you log in. This can help you clear temporary files, reset processes that hog memory resources, and close background apps that don't need to run right away. This results in a computer that consistently feels fresh, fast, and efficient.

Rather than manually cleaning my computer or shutting down certain startup apps, I use Task Scheduler to run a script that does these tasks for me whenever the computer is switched on.

Here’s the script:

# The Clean Slate Power-Up Script
# Safely close running background apps

$appsToClose = "Spotify", "Teams", "Discord"
foreach ($app in $appsToClose) {
Get-Process -Name $app -ErrorAction SilentlyContinue | Stop-Process -Force
}

# Delete files in the temp folder older than 3 days

$paths = @("$env:TEMP", "$env:LOCALAPPDATA\Temp", "C:\Windows\Temp")
foreach ($path in $paths) {
if (Test-Path $path) {
Get-ChildItem -Path $path -Recurse -Force -ErrorAction SilentlyContinue |
Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-3) } |
Remove-Item -Force -Recurse -ErrorAction SilentlyContinue
}
}

My script closes Spotify, Teams, and Discord at login and deletes files in the Temp folder every three days. You can customize this and add more tasks.

To automate the task, I follow these steps:

  1. Save the above script with a .ps1 extension. In my case, CleanSlate.ps1.
  2. Search for and launch Task Scheduler, then click Create Task in the right pane.
  3. Fill in the Name field, select Run with highest privileges, then under Configure for, select Windows 10 (this is fine even if you use Windows 11).
  4. Go to the Triggers tab, click New, then select At log on from the Begin the task drop-down, then click OK.
  5. Go to the Actions tab and click New. Under Program/script, enter: powershell.exe, then in Add arguments, enter: -ExecutionPolicy Bypass -File "C:\Scripts\CleanSlate.ps1"
  6. Click OK.

This task is the perfect way to clean up your PC. It runs silently, and you'll start with a lean, fast system every day.

Context-aware backup when connecting a drive

Your external drive becomes the trigger

I configured a rule with Windows Task Scheduler that automatically backs up whenever I plug in my external disk. This automation uses the native Windows Robocopy utility to mirror key folders like my Documents, Projects, and Downloads. Everything remains synchronized without me doing anything.

Below is the script I use:

# Context-Aware Backup Script
$source = "$env:USERPROFILE\Documents"
$destination = "E:\Backups\Documents"
$log = "E:\Backups\backup_log.txt"
Robocopy $source $destination /MIR /R:2 /W:3 /LOG:$log

In the script, $source sets the folder to back up, $destination is where the backup goes, and $log specifies the log file where Robocopy logs everything it copies.

To create this automation:

  1. Launch the Task Scheduler, click Create Task in the right pane, then fill in the Name field.
  2. Navigate to the Trigger tab and set Begin the task to On an event.
  3. Set Log to Microsoft-Windows-DriverFrameworks-UserMode/Operational.
  4. Set Event ID to 20001, then click OK.

Event IDs may vary, but you can confirm yours: plug in your drive, open Event Viewer, and navigate to Windows Logs -> System. Then filter by Kernel-PnP and find the Event ID.

With this automation, the system will sync the latest changes and update your drive the moment you connect it. It's possible to make the script more elaborate, including additional folders or adding completion notifications.

Privacy shadow sweep

Clear personal data while you sleep

It's almost impossible to completely disable telemetry on Windows 11. Even though Windows telemetry is not malicious, it becomes a privacy footprint. I have a privacy shadow sweep that runs every night. It automatically clears digital residue and allows me to start anew in the morning.

This task rests on a PowerShell script that deletes Windows diagnostic logs, cached Wi-Fi profiles, recent file lists, and app telemetry remnants. Below is my script:

# Privacy Shadow Sweep
# Clear the PCs Diagnostic Logs

Remove-Item -Path "C:\ProgramData\Microsoft\Diagnosis\ETLLogs" -Recurse -Force -ErrorAction SilentlyContinue

# Remove your Recent Items and Quick Access

Remove-Item -Path "$env:APPDATA\Microsoft\Windows\Recent\*" -Force -ErrorAction SilentlyContinue

# Clear browser caches (Edge and Chrome)

$edge = "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Cache"
$chrome = "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Cache"
Remove-Item -Path $edge,$chrome -Recurse -Force -ErrorAction SilentlyContinue

# Get a summary of log cleanup

$report = "C:\Logs\PrivacySweep_$(Get-Date -Format 'yyyyMMdd').txt"
"Privacy Sweep completed at $(Get-Date)" | Out-File $report -Encoding **UTF8**

To automate this task, make sure that in Task Scheduler, Triggers is set to Daily. Select the time it should run, then in the Conditions tab, enable Start the task only if the computer is idle.

Adaptive performance mode for heavy apps

A temporary power boost when you need it most

This may just be my favorite automation, because I get performance on demand. Running resource-intensive apps can be draining on your computer. However, I have an automation that fixes slowdowns. With this, when I launch a resource-heavy app like Blender, Windows will kill unnecessary background apps and raise the heavy app's process priority. Once I close the heavy app, Windows ends this high-performance mode and everything goes back to normal.

This is one automation where I won't use the Task Scheduler since implementing it is more complex. I may even need two separate tasks for it: one triggered On app launch and the other On app exit.

Below is the script that I use. It's written for Blender, but you can modify it for any heavy apps you have. You may create a shortcut to this script or run it once at login; it stays active until the heavy app closes.

# Adaptive Performance Mode Watcher Script

$appName = "blender"
$backgroundApps = "Spotify", "Teams", "Discord"

# Performance boost at heavy app startup

Start-Process -FilePath "C:\Program Files\Blender Foundation\Blender 4.0\blender.exe"
Start-Sleep -Seconds 10

# Close all running and unnecessary background apps

foreach ($app in $backgroundApps) {
Get-Process -Name $app -ErrorAction SilentlyContinue | Stop-Process -Force
}

# Sets the app priority to High

$process = Get-Process -Name $appName -ErrorAction SilentlyContinue
if ($process) { $process.PriorityClass = 'High' }

# Wait for the heavy app to exit

Wait-Process -Name $appName

# Restore closed background apps

foreach ($app in $backgroundApps) {
Start-Process $app -ErrorAction SilentlyContinue
}

End-of-day focus reminder and auto-shutdown

A gentle nudge to log off and recharge

I'm fond of having my day spill into the night. My computer is often left with cluttered open windows, half-finished tasks, and sometimes memory-hugging apps. I resolved this with a Task Scheduler automation that gradually shuts the computer down after reminding me to wrap it up. I get the reminder 15 minutes before shutdown. It gives my computer a good rest and a clean ending to each day.

For this, I have two different tasks in Task Scheduler. This is how I create the first:

  1. Launch the Task Scheduler and create a task. I call it "Focus Reminder".
  2. Select Run whether user is logged on or not and check Run with highest privileges.
  3. Navigate to the Triggers tab and click New. Select Daily and pick the time you want it to run, then click OK.
  4. Navigate to the Action tab and click New. Enter powershell.exe for Program/script, then in Add arguments (optional), type the following and hit OK:
-ExecutionPolicy Bypass -WindowStyle Hidden -Command "Add-Type -AssemblyName PresentationFramework; [System.Windows.MessageBox]::Show('Wrap up your tasks — system will shut down in 15 minutes.', 'Focus Reminder')"

Here is the second task:

  1. Launch the Task Scheduler and create a task. I call it "Auto Shutdown".
  2. Select Run whether user is logged on or not and check Run with highest privileges.
  3. Navigate to the Triggers tab and click New, then select Daily. Enter a time 15 minutes after your "Focus Reminder" task, then click OK.
  4. Navigate to the Action tab and click New. Enter shutdown.exe for Program/script, then in Add arguments (optional), type the below, followed by OK to save the task.
/s /f /t 60 /c "System shutting down. Save your work now."

Now you will get a warning and have 15 minutes to turn off your computer until it's time to focus on other important matters.

Take control of your Windows workflow with automation

With these automations, I become a proactive participant in my workflow. I remove some friction with each script or scheduled action and free myself from repetitive chores. However, these five are just a starting point. You can add to the list based on your computer use and workflow.

The goal is to automate your daily tasks on Windows and create a consistent and reliable environment that is perfectly adapted to you.

AltStyle によって変換されたページ (->オリジナル) /