how to remove old windows folder in windows 10 code example

Example 1: remove windows folder from old drive

Open a command line as administrator and copy these lines one by one:
Note: replace the folder address to the folder you want to remove

takeown /F "Z:\Program Files" /A /R /D Y

icacls "Z:\Program Files" /T /grant administrators:F

rd /s /q "Z:\Program Files"

if it didn't delete the folder fully do the steps again from top to buttom once more

Example 2: Can i remove Windows old folder

/* -----------------------
As long as you have no plans to roll back to a previous version
you can delete using Disk Cleanup. (:

How to recover/restore your previous version of Windows
using the Rollback feature:
http://answers.microsoft.com/en-us/insider/wiki/insider_wintp-insider_install/how-to-recover-restore-your-previous-version-of/76b6750c-5bb2-40bc-a7e3-f03cec62338b
----------------------- */