The short script has only 3 rows. Code: TAKEOWN /F %SystemDrive%\Windows.old /A /R /D Y ICACLS %SystemDrive%\Windows.old /T /grant :r Administrators:F RD /S /Q %SystemDrive%\Windows.old Powershell script: Code: $regpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations" New-ItemProperty -Path $regpath -Name "StateFlags1221" -PropertyType DWORD -Value 2 -Force | Out-Null $regpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\update Cleanup" New-ItemProperty -Path $regpath -Name "StateFlags1221" -PropertyType DWORD -Value 2 -Force | Out-Null $regpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\System error memory dump files" New-ItemProperty -Path $regpath -Name "StateFlags1221" -PropertyType DWORD -Value 2 -Force | Out-Null #start clean application cleanmgr.exe /SAGERUN:1221
Show us the error. I recently wanted to cleanup a leftover mount folder (when testing the new W10UI and MUI scripts), it took me over 2hrs doing it manually, by rebooting to safe mode and deleting the files, by booting into to winre environments, and ended up in taking over ownerships for every file that didn't want to be deleted. After that @abbodi1406 showed me the nsudo method and the folder was gone in a few seconds.
C:\Windows.old\WINDOWS\appcompat\Programs\Install - The directory is not empty. (The directory is empty)
Usually I run 7zip as admin, and using shift+delete I can delete any folder with that stupid "directory is not empty" error.
Try RunAsTI by @BAU https://forums.mydigitallife.net/threads/lean-and-mean-snippets-for-power-users.83479/