Hello!
I'm sorry to hear that you're having trouble with cleanmgr.exe. It's possible that the command line parameters you're using are not correct. Here's an example of how to use cleanmgr.exe with the /SAGERUN parameter:
cleanmgr /SAGERUN:1
This should run the Disk Cleanup tool with the settings saved in the first SAGERUN key in the registry. If this doesn't work, you can try running the command with elevated privileges by opening PowerShell or CMD as an administrator.
If you're still having trouble, you can try using the PowerShell cmdlet "Invoke-WmiMethod" to run the Disk Cleanup tool. Here's an example:
Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList "cleanmgr.exe /SAGERUN:1"
This should run the Disk Cleanup tool with the same settings as before. If this doesn't work, you may need to troubleshoot further for additional assistance.
Hello! Thanks for the reply
I have already tried both ways and got the same result. As I already said, I've tried many parameters as of course the cleanmgr.exe /SAGERUN:1 On both CMD and PowerShell, and all the possible powershell's commands such as the invoke-expression, invoke-wmimethod-class, start-process and so on, none worked. I have tested in more than 10 PCs plus of course I tried to use the help of Google bard and chatgpt before coming here, nothing worked in none of them. As I said, when I try to run the cleanmgr.exe via CLI, it OPENS the utility's window and RUNS as it should apparently without issues, but when I OPEN AGAIN the cleanmgr.exe just to see if the files were deleted, boom, they are all there, no matter if I put Verb RunAs on code to make it run with admin permissions. But if try to run it via GUI it works perfectly, just clicking on "ok" and it really deletes all the files it should delete. That said, I believe the problem is more low-level system than just see if the code sintax is right and try many different ways of doing the same thing.