I'm trying to run Disk Cleanup using VSA X, which executes tasks via the system account. While I can see that the task is running on the computer, nothing is actually being cleaned up. I'm also wondering whether cleanmgr can operate without a user being logged in. Here's the script I'm working on: https://pastebin.com/up21b74C.
3 Answers
Take a close look at line 35 of your script. It seems like you're missing a backslash between `VolumeCaches` and `$item`. The right way to reference it is like this: `HKLM:SOFTWAREMicrosoftWindowsCurrentVersionExplorerVolumeCachesActive Setup Temp Folders`. Make sure to add that backslash!
Hey there! Just a heads up, it seems there might be a problem with the path you're using. Check out the examples for Get-Help Join-Path to fix that. It could be the reason nothing is being deleted. Hope this helps!
Great to see you back and kicking! 🙂
It looks like you missed an important parameter. Make sure to add **-Wait** to the Start-Process command. This way, cleanmgr will complete its cleaning before the process ends. Without that, it can quit before actually doing anything!
Thanks, I'll add that in! So just to clarify, without the wait, cleanmgr probably shuts down too quickly to clean anything, right?

I appreciate your help! I’ll make those edits right away.