Pages

Friday, July 27, 2012

Take the ownership of a file in Windows

This is just a simple command to take the ownership of a file in Windows

1. Open Start menu and enter cmd in the Search box.


2. Navigate to your file's directory in the command prompt. ( e. C:\Files\myfile.exe)

Then type in the following command:

Code:
takeown /f myfile.exe
You should get a success message once this is completed.

Quote:
SUCCESS: The file (or folder): "C:\Filesz\myfile.exe" now owned by user "ComputerName\username"
where

ComputerName = Your Computer's Name
username = Your user name

3. 
That will give you ownership of the file, but you still have no rights to delete it. Now you can run the cacls command to give yourself full control rights to the file:
Code:
cacls myfile.exe /G username:F
You need to substitute your user name in place of username .


Notes
-----
  • To take ownership of a folder and all its content, you can add the /r switch for recursive execution:
Code:
  takeown /f . /r
  • You can also use the /a switch to make the ownership go to the Administrators group instead of the current user:
    Code:
      takeown /f intlcfg.exe /a