takeown /F "<folder name>" /A /R /D Y icacls "<folder name>" /T /grant administrators:F rd /s /q "<folder name>"
In the above, replace with the full pathname of the folder you are trying to delete e.g. “Z:\Program Files” – make sure that you keep the quotes.