Can you help me to make the Disk Clean Up Procedure runs in the background? I am using the script below which runs as a logged in user, but it shows a GUI (showing the Disk Cleanup Progress Bar) which might accidentally close by a user once we executed the procedure. Also, can we delete the following Data/Logs using this procedure:
Setup Log Files
Downloaded Program Files
Temporary Internet Files
System archived Windows Error Reporting
System queued Windows Error Reporting
System created temporary Windows Error
Delivery Optimization Files
Temporary Files
Thumbnails
EXCEPT Recycle Bin.
Below is the script that I am using.
import os
print(‘Disk Cleanup has been completed.’)
clean=os.popen(‘cleanmgr.exe /sagerun:1’).read() # should works in both 32-bit and 64-bit
print(clean) # cleanmgr run from gui and don’t return anything, this should be empty
Hi @apanelo
We could not able to create the script to perform the disk clean without any interaction using the built-in tool like “cleanmgr.exe /sagerun:1”.
Because the file categories should be selected for deletion.
1.Setup Log Files
2.Downloaded Program Files
3.Temporary Internet Files
4.System archived Windows Error Reporting
5.System queued Windows Error Reporting
6.System created temporary Windows Error
7.Delivery Optimization Files
8.Temporary Files
9.Thumbnails