How to Manually Run Storage Sense Cleanup From Command Line
🔍 WiseChecker

How to Manually Run Storage Sense Cleanup From Command Line

Quick fix: Open PowerShell (Admin). Run: Start-Process "cleanmgr.exe" -ArgumentList "/sagerun:1" -Verb RunAs. For Storage Sense specifically (not Disk Cleanup): there’s no direct CLI; trigger via registry: schtasks /run /tn "\Microsoft\Windows\DiskCleanup\SilentCleanup". This runs the same cleanup that Storage Sense would.

Storage Sense is the Windows 11 setting that auto-deletes temp files, old downloads, recycle bin items on a schedule. To force it to run now: trigger the SilentCleanup scheduled task, or invoke Disk Cleanup with command-line flags.

Symptom: Want to manually trigger Storage Sense or Disk Cleanup from command line on Windows 11.
Affects: Windows 11 (and Windows 10).
Fix time: ~5 minutes.

ADVERTISEMENT

What causes this need

Manually running Disk Cleanup via GUI is slow. Scheduling via Storage Sense waits for the next scheduled time. For: scripting cleanup, freeing space after a big install, cleanup before backup, automation in PowerShell — you need CLI access. Two paths: cleanmgr.exe (Disk Cleanup) and the SilentCleanup scheduled task.

Method 1: Run Disk Cleanup with preset profile

The standard route.

  1. First, create a cleanup profile. Open Admin Command Prompt.
  2. Run: cleanmgr /sageset:1. UI opens.
  3. Tick items to clean: Temporary Files, Recycle Bin, Windows Update Cleanup, Delivery Optimization, Thumbnails, etc.
  4. Click OK. Profile saved as profile 1.
  5. To run the profile silently:
    cleanmgr /sagerun:1

    Cleanup runs in background. UI shows progress.

  6. For multiple profiles (different settings): use /sageset:2, /sageset:3, etc.
  7. For automatic schedule: Task Scheduler → create task → run cleanmgr /sagerun:1 weekly.
  8. For listing all items cleaned: check Volume size before and after.

This is the standard CLI approach.

ADVERTISEMENT

Method 2: Trigger Storage Sense scheduled tasks

For triggering the Windows-managed cleanup.

  1. Open Admin Command Prompt or PowerShell.
  2. List relevant tasks:
    schtasks /query /tn "\Microsoft\Windows\DiskCleanup\SilentCleanup"

    Shows the SilentCleanup task — the one Storage Sense uses.

  3. Run the task:
    schtasks /run /tn "\Microsoft\Windows\DiskCleanup\SilentCleanup"

    Runs in background. May take 5-30 minutes depending on file count.

  4. For Storage Sense’s schedule settings: Settings → System → Storage → Storage Sense. Configure intervals, what to clean.
  5. For PowerShell trigger:
    Start-ScheduledTask -TaskPath "\Microsoft\Windows\DiskCleanup\" -TaskName "SilentCleanup"
  6. Monitor: Task Scheduler → Microsoft → Windows → DiskCleanup → SilentCleanup → Last Run Result shows success/error.
  7. Caveat: SilentCleanup uses Disk Cleanup’s default profile, not Storage Sense’s. Storage Sense itself runs only on its own schedule.

This is the scheduled-task trigger.

Method 3: Use PowerShell module or write custom cleanup

For granular control.

  1. For specific item types beyond Disk Cleanup’s scope:
    # Clear all user temp files
    Get-ChildItem $env:TEMP -Recurse -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
    # Clear Windows Defender quarantine
    Get-ChildItem "$env:ProgramData\Microsoft\Windows Defender\Scans\*" -Recurse | Remove-Item -Recurse -Force
    # Clear browser caches (close browsers first)
    Remove-Item "$env:LOCALAPPDATA\Microsoft\Edge\User Data\Default\Cache" -Recurse -Force
    # Clear thumbnail cache
    Stop-Process -Name explorer -Force
    Remove-Item "$env:LOCALAPPDATA\Microsoft\Windows\Explorer\thumbcache*.db" -Force
    Start-Process explorer
  2. Save as .ps1 script. Run as Admin.
  3. For automation: Task Scheduler trigger script weekly.
  4. For older files in Downloads: delete files older than N days:
    $daysOld = 30
    Get-ChildItem "$env:USERPROFILE\Downloads" -Recurse | Where-Object {
        $_.LastWriteTime -lt (Get-Date).AddDays(-$daysOld)
    } | Remove-Item -Recurse -Force
  5. For shadow copies cleanup: vssadmin delete shadows /for=C: /oldest (deletes oldest).
  6. For Windows Update cleanup specifically: dism /online /cleanup-image /startcomponentcleanup /resetbase. Deep cleanup.
  7. For OneDrive cache management: not via Disk Cleanup. Right-click OneDrive icon → Settings → Free up disk space.

This is the deep custom approach.

How to verify the fix worked

  • Settings → System → Storage shows disk usage breakdown. Temporary files / Recycle Bin amounts dropped.
  • C: drive free space increased.
  • Task Scheduler → SilentCleanup shows Last Run Result: 0x0 (success).
  • cleanmgr.exe output (if you used Method 1) shows cleanup completed.

If none of these work

If cleanup runs but no space freed: Items not selected in profile: re-run cleanmgr /sageset:1 and tick more categories. System file cleanup: need elevated rights. Run cleanmgr as Admin. Permissions on AppData / Temp: some files in use can’t delete. Reboot first. Windows.old folder: 10-25GB after major upgrade. Use cleanmgr with “Previous Windows installation(s)” ticked. For chronic full disk: WinDirStat or WizTree shows what’s actually using space. Address that. For Storage Sense not running scheduled: Settings → Storage → Storage Sense → verify it’s enabled and run schedule set. For deep system clean: dism /online /cleanup-image commands free more space than Disk Cleanup.

Bottom line: Set up profile with cleanmgr /sageset:1, run with cleanmgr /sagerun:1. Or trigger Windows’s SilentCleanup task: schtasks /run /tn "\Microsoft\Windows\DiskCleanup\SilentCleanup".

ADVERTISEMENT