I'm trying to run Disk Cleanup using the VSA X tool, which operates under the system account. I can see that the task is running on the computer, but it doesn't seem to clean anything. Also, does cleanmgr work if the user is not logged in? Here's my script for reference: https://pastebin.com/up21b74C.
3 Answers
Check out line 35 in your script. You're missing a backslash between `VolumeCaches` and the variable `$item`. Here’s how it should look in the registry: `HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionExplorerVolumeCachesActive Setup Temp Folders`. That should solve the path issue!
It looks like you missed a key parameter: Start-Process -Wait. Adding -Wait should help because without it, the cleanmgr process might be closing too quickly to actually complete the cleanup.
Hey, just a heads-up—according to what CodenameFlux mentioned, you might have a faulty path in your script. Check out `Get-Help Join-Path -Examples` for the right way to fix it. Hope that helps!

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures