question

VSRawat-2658 avatar image
0 Votes"
VSRawat-2658 asked JennyFeng-MSFT commented

How to run Disk Cleanup unattended? (batch command, etc.)

I had posted the same here but someone suggested there that I post here, so repeating here.

Problem of Disk Cleanup taking hours is not the only one, another aspect of the problem is that it has many phases that it goes through sequentially and we cannot skip though that.

  1. When I start it, it takes long time to give the first screen of basic files.

  2. If you chose to clean those basic files, it does so, and closes.

  3. You have to start it afresh to clean system files.

  4. If you want to clean system files, it still starts with basic files cleaning screen, going through entire process again dutifully.

  5. I cannot make it directly go to system file cleaning screen, bypassing basic file cleanup.

  6. For both, basic files, and system files, it first takes hours in figuring out what to clea, then you have to give command, and then it taken another span of hours to clean up.

  7. I cannot make it skip that "calculation" part, and rather directly just clean it, and clean it both, basic and system files in one go.

One method could be that we be allowed to run Disk Cleanup throught some batch file and it runs unattended. We can give the command two times, one for basic files, then for system files, and it does its long steps in the background. We don't have to standby to attend to it. There could be command line options that can tell whether to clean basic files of system files or both, and whether to first calculate, or directly go to cleaning anyway. That will save a lot of time and attention one needs to pay to it.

if it uses dism, are there such options in dism commands to run directly as required above?

If someone knows how to do any of the above (different from default sequence), please share.

How can I run Disk Cleanup unattended as described above?

I am on w8.1-64 bit, but the same problem is there in all windows (7, 10...).


windows-8
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@VSRawat-2658
Hi,

Just checking in to see if the information provided was helpful.

If the reply helped you, please remember to accept as answer.
If no, please reply and tell us the current situation in order to provide further help.

0 Votes 0 ·

@VSRawat-2658
Hi,

We have not get information from you for several days.

If the reply is useful for you, please accept as answer. It will be helpful to other members who have same questions.
If you have any other confuse, please reply to us directly.

0 Votes 0 ·

1 Answer

JennyFeng-MSFT avatar image
0 Votes"
JennyFeng-MSFT answered

@VSRawat-2658
Hi,
The cleanmgr.exe tool has two important switches: /SAGESET and /SAGERUN
The way these switches work is you manually run the following command on a particular computer at the cmd prompt:
cleanmgr.exe /SAGESET:123

What you can do to automate everything is run the cleanmgr tool with /SAGESET on a single computer. Then evaluate which registry values it created, and then write a script that will create the same registry values.

For your reference:
https://batchpatch.com/running-the-disk-cleanup-tool-cleanmgr-exe-remotely-on-multiple-computers

In addition, here are some posts with the similar issue with yours, just for your reference, you can try the method mentioned in them:
https://www.reddit.com/r/sysadmin/comments/adhuwy/silently_run_disk_cleanup_with_nno_user_prompt/
Please note: Information posted in the given link is hosted by a third party. Microsoft does not guarantee the accuracy and effectiveness of information.

Hope above information can help you.

============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.