Automating Disk Cleanup with cleanmgr Command-Line Options

Download now

cleanmgr.exe supports command-line switches that let you save a cleanup profile and re-run it silently, including on a schedule.

Updated August 9, 2026 · PC Utility Hub Editorial Team

Create a cleanup profile with /sageset

The /sageset switch opens the full Disk Cleanup category list (including system file categories, no elevation prompt needed for the file-system-files button) and saves your selections under a numeric profile ID stored in the registry.

  1. 1Run the command above from an elevated Command Prompt or Run dialog.
  2. 2Check every category you want included in this profile.
  3. 3Click OK; nothing is deleted yet, only the profile is saved.
cleanmgr /sageset:1

Run a saved profile with /sagerun

Once a profile is saved, /sagerun executes the cleanup for that ID with no dialog, deleting files matching your saved choices immediately.

cleanmgr /sagerun:1

Warning: There's no confirmation prompt with /sagerun. Files matching the saved categories are deleted immediately, so review the profile carefully with /sageset first.

/verylowdisk for automatic low-space cleanup

/verylowdisk runs cleanup automatically without any user interaction, intended for scenarios where disk space is critically low, such as OOBE or automated deployment scripts. It selects a default set of safe categories without requiring a saved profile.

cleanmgr /verylowdisk

Automate with Task Scheduler

  1. 1Save a profile first with `cleanmgr /sageset:65` (any unused number).
  2. 2Open Task Scheduler and create a new task.
  3. 3Under Actions, set the program to `cleanmgr.exe` and arguments to `/sagerun:65`.
  4. 4Set a trigger, such as weekly or at logon.
  5. 5Under General, check "Run with highest privileges" so system file categories are included.

Other useful switches

SwitchPurpose
/d <drive>Target a specific drive letter
/sageset:nOpen full category picker and save as profile n
/sagerun:nSilently run cleanup profile n
/verylowdiskRun a default cleanup with no UI, for low-space situations
/lowdiskSimilar to /verylowdisk but shows a confirmation dialog

Frequently asked questions

Does /sagerun ask for confirmation before deleting?
No, it deletes files matching the saved profile immediately without a prompt.
Can I run cleanmgr for a non-system drive?
Yes, use the /d switch, e.g. `cleanmgr /d D: /sagerun:1`.
Is there a PowerShell-native alternative?
Storage Sense can be configured via Settings or Group Policy for similar automated cleanup without cleanmgr.