How to Take ownership of a file or folder from the command prompt

To take ownership of a file or folder run the following commands from a command prompt with elevated privileges.

Right click cmd.exe and select run as, then select the administrator account and provide the password for the administrator.

Change the directory to the directory or file that you need to regain permissions on.

How to take ownership of files using the command prompt :
TAKEOWN /F <filename>

Now run the following command to assign the administrators group full control of the file

ICACLS <filename> /grant administrators:F

How to take ownership of folders using the command prompt :
takeown /f <foldername> /r /d y

Now assign the administrators group full control of the folder by running the following command : 
icacls <foldername> /grant administrators:F /T

Was this answer helpful? 2 Users Found This Useful (2 Votes)