Permission denied when copying files on Windows

Use takeown to take ownership of the file

takeown /r /d y /f *

^ Recursively takes ownership of all files without prompting “are you sure”.

Follow it up with icacls set the access control list

icacls * /grant Everyone:F /t /c /q

This will recursively grant Full access to user group “Everyone” to all files in the folder.

the current logged on user does not have ownership privileges on the file (or folder) security error on Windows

Error message

the current logged on user does not have ownership privileges on the file (or folder)

Solution

Make sure your command prompt is elevated, otherwise it won’t have admin rights even though you are an “admin”.

To open an elevated command prompt, search for cmd in your start menu and press CTRL + SHIFT + ENTER or right click on it and choose Run as administrator.

Confirm it is elevated by looking for “Administrator:” prefixed to the window title.

TAKEOWN /F <DIRECTORY> /R /D Y