Taking Ownership of a File or Folder from the Command Line
With the Takeown.exe command-line tool, administrators can take ownership of a file or folder.
April 17, 2014
Q: How can I take ownership of a file or folder from the command line?
A: In Windows Vista, Microsoft introduced the Takeown.exe command-line tool, which can be used to take ownership of a file or folder. You need to run this tool from an elevated command prompt window. (Click Start, open the Accessories folder, right-click Command Prompt, and click Run as administrator.)
To take ownership of a file, run the command:
takeown /F
In this command, you must replace with the full file system path to the file you want to take ownership of. If the command is successful, you'll see a message similar to the following: SUCCESS: The file (or folder): "filename" now owned by user "Computer NameUser name".
To take ownership of a folder, use the command:
takeown /f /r /d y
In this command, you must replace with the full file system path to the folder you want to take ownership of. You need to include the /r switch when you want to also take ownership of all the subfolders and files in the specified folder. You can use the /d switch to specify the default answer the tool should use when it comes across subfolders for which you don't have List Folder permissions. In this case, the default answer is y (which stands for yes), meaning that the tool will allow you to take ownership of those subfolders, even though you don't have List Folder permissions.
To get a detailed overview of the Takeown command syntax, run the command:
takeown /?
About the Author
You May Also Like