Mastering Cleanmgr: How to Use /sageset:1 and /sagerun:1 to Free Up Space in Windows

Last update: 30/07/2025
Author Isaac
  • The cleanmgr command with /sageset and /sagerun allows you to customize and automate disk cleanup in Windows.
  • Setting up multiple cleaning profiles helps you manage different tasks and save space easily.
  • Automation with scheduled tasks and registry modification streamlines system maintenance.

cleanmgr disk cleanup

Tired of your computer filling up with useless files and losing performance? Many Windows users are unaware of the more advanced options for keeping their computer clean and fast, relying solely on manual cleaning or third-party tools that are often unnecessary. However, Microsoft's operating system offers a native tool, cleanmgr.exe, with little-exploited functions such as modifiers /sageset y /sagerun which allow you to effectively free up space and automate the process.

This article teaches you how to use "/sageset:1" and "/sagerun:1" in the cleanmgr command. to manage your equipment cleaning professionally, setting up custom profiles and scheduling automatic tasks that will save you time and effort. Discover Tricks, parameters, profiles and ways to avoid problems with Temporary files and caches, from the line of commands, the registry and even through batch scripts.

What is cleanmgr and why should you use it?

Cleanmgr.exe is the Windows Disk Cleanup tool, designed to remove unnecessary files, gain space, and improve overall system performance.

Its true power is unlocked through the command line, allowing greater customization and control over which files to delete, as well as the creation of profiles tailored to different needs.

Using the command line is not only faster and more efficient, but also allows you to automate tasks and create scripts, facilitating periodic maintenance of the equipment without constant manual intervention.

How cleanmgr works with /sageset:1 and /sagerun:1

The command cleanmgr supports modifiers that control its behavior. The main ones to customize and automate are /sageset:n y /sagerun:n, where “n” is a profile identification number (between 0 and 65535).

  • /sageset:1: Opens a window to select the file categories you want to delete (temporary, cache, trash, system files, etc.). The setting is stored in the registry, linked to number 1 in this example.
  • /sagerun:1: Automatically runs cleaning using the categories configured in Profile 1, without displaying the selection interface. Ideal for automated routines.
  Tutorial: How to Delete Unwanted Files or Folders in Windows

These commands can be combined with other modifiers such as /d (for the drive), /lowdisk, /verylowdisk, or in scripts and scheduled tasks.

automate disk cleanup cleanmgr

Steps to configure cleanup profiles with /sageset and /sagerun

  1. Opens CMD as administrator: Search for “cmd” in the Start menu, right-click, and select “Run as administrator.”
  2. Type the command to define the cleaning profile:
    cleanmgr /sageset:1
    The window will open to select the file categories to clean.
  3. Check the desired options: select temporary files, caches, trash, logs, thumbnails, error files, old Windows files, cache, etc.
  4. Click OK: The configuration is saved in the registry under profile 1.
  5. Run automated cleanup with sagerun:
    cleanmgr /sagerun:1
    >The releaser will only delete the categories selected for profile 1 on all drives.

You can create as many profiles as you want., using different numbers, for different periodic cleaning routines, whether daily, weekly or monthly.

Cleanmgr Advanced Options: Available Parameters

In addition to /sageset and /sagerun, the command allows other useful modifiers:

Parameter Description
/d Specifies the drive to be wiped. *Not used with /sagerun:n*
/sageset:n Opens the selection window and saves settings to the registry.
/sagerun:n Runs cleanup according to the settings stored in profile “n”.
/tuneup:n Combine /sageset and /sagerun for the same value "n".
/lowdisk Runs cleanup with predefined options when low space is detected.
/verylowdisk Similar to /lowdisk, without displaying user messages.
/autoclean Automatically removes residual files after Windows updates.
/? Displays help for the command.

What file categories can you clean with cleanmgr?

when you use /sageset, a dialog box appears allowing you to select from several file categories, which may vary depending on the version of Windows and the applications installed. Among the most common are:

  • Temporary installation files: remnants of installation processes that are no longer necessary.
  • Downloaded program files: ActiveX and Java controls stored temporarily.
  • Temporary Internet files: web pages and browser cached content.
  • Old chkdsk files: fragments created during disk checks.
  • Recycle Bin: Deleted files that are still taking up space.
  • Temporary files: created by programs, which can be deleted if not used.
  • Temporary Offline Files y offline files: local copies of network files.
  • Old compressed files: infrequently used files that can be compressed to save space.
  • Index and log files: remnants of indexing operations and error reports.
  How to Repair and Recover Corrupted Microsoft Office Files: Step-by-Step Solutions

Remember that some files are only deleted if they are more than a week old., this can be adjusted by modifying the registry.

Where are the settings stored? The role of the registry

Each profile configured with /sageset:n It is stored in the registry in the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches. Each option has a value StateFlagsXXXX, where XXXX corresponds to the chosen profile.

This way, you can export this key and replicate settings to other computers, making management easier in multi-computer environments. To expand your knowledge on how to keep Windows running smoothly, you can check out The best tools for Windows 11 maintenance.

The value 2 in StateFlagsXXXX activates the option, while 0 deactivates it. It is also possible to manually edit the registry to further customize profiles.

Full automation: scheduling periodic cleaning

A key advantage One of these commands is the ability to automate cleaning by creating scheduled tasks in Windows:

  1. Generates a batch file, for example, cleandisk.bat, with:
    cleanmgr /sagerun:1
  2. Open the task scheduler with taskschd.msc
  3. Create a new task, assigning the batch file to it and setting the desired frequency (daily, weekly, monthly).

This way, your computer will stay clean automatically, without manual intervention, as Windows will manage the cleaning efficiently and silently.

Creating and managing profiles: practical examples

  • cleanmgr /sageset:1: quick cleaning for daily use (trash, temporary).
  • cleanmgr /sageset:3: weekly maintenance (temporary, trash, logs).
  • cleanmgr /sageset:5- Monthly deep cleaning (almost everything except thumbnails and indexer).
  • cleanmgr /sageset:7: : only miniatures, for special occasions.

Use these profiles in scripts or scheduled tasks to adapt the cleaning to different needs, always using the same numbers in sageset and sagerun so that the settings match.

What other commands complement cleanmgr?

For a more thorough cleanup, you can combine cleanmgr with other system commands, such as:

  • del %temp%\*.* /s /q: Deletes temporary files from the user profile.
  • del C:\Windows\Prefetch\*.* /s /q: deletes prefetch files.
  • ipconfig / flushdns: : clears the DNS cache.
  • wsreset.exe: Clear the Windows Store cache.
  • defrag C:: defragments the hard drive (not in SSD).
  Use NFC Tag Reader on iPhone

These commands can be integrated into scripts to perform more thorough cleaning.If you want to delve deeper into optimizing your system, we recommend visiting How to free up RAM in Windows.

Recover and replicate settings on other PCs

To apply the same settings on multiple computers, export the key VolumeCaches in the registry from a base team (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches) and then import it into others. This way, you'll be able to run cleanmgr /sagerun:n on all devices with the same profiles.

It is especially useful in environments with multiple computers, classrooms or businesses.

Common mistakes and recommendations

  • Run CMD as administrator to grant appropriate permissions to cleanmgr.
  • If you use /sagerun without having previously configured the profile with /sageset, cleaning will not be performed.
  • Close programs that may lock temporary files before running deep cleans.
  • Do not combine /d and /sagerun: The /d option is used with regular cleanmgr or /sageset, but not in conjunction with /sagerun.
  • Compressing old files only reduces the size, it does not delete data.
Schedule temporary file cleanup in Windows 11-8
Related article:
How to schedule automatic temporary file cleanup in Windows 11