Easier Way to Take Ownership and Grant Access Files or Directories in Vista

In Windows Vista, there are lots of files and directories especially those operating system files plus Windows and Windows\System32 folders have been protected. These protected system files aren’t belong to any users or groups, instead are owned by TrustedInstaller, with even Administrator or Administrators group doesn’t have modify or write access to them. Thus if you intend to manipulate or replace the files, you’ll encounter access denied error even though you are administrator and have disabled UAC or already in elevation mode for the application trying to access.

In this case, users will probably have to right click on the object, then access the object’s properties. Then users have to click on Security tab, click on Advanced button, click on Owner tab, and then perform several clicks and confirmations to take ownership of the object. The whole process have to repeat again to grant read-write-modify or full control access rights to the users. The whole process takes lengthy time, troublesome, involves lots of clicks and steps. To simplify the process, simply download the TakeControlOf.cmd command line batch script, which will automatically take ownership and grant full control access rights by assigning new ACLs (Access Control Lists) to the file or directory that input to the command.

Download TakeControlOf.zip from the forum.

TakeControlOf.cmd makes use of two command-line utilities takeown (takes ownership of a file or directory) and icacls (sets new ACLs on a files or directory) respectively. Full Control access privilege will be given to Administrators group.

To use the batch script, simply launch an elevated command prompt, then run the script. Below is same examples (command should be issued from the directory where you store the TakeControlOf.cmd script):

TakeControlOf C:\Windows\Test_File.exe
TakeControlOf C:\Test_Directory

Note that if you specify a directory, the script will works recursively to include all subdirectories. To change this behavior, edit the TakeControlOf.cmd and remove /r from the takeown (first) line, and /t from icacls (second) line.

19 Responses to “Easier Way to Take Ownership and Grant Access Files or Directories in Vista”

  1. Vista File Security Sucks « Personally Challenging™
    December 1st, 2009 21:58
    19

    [...] found a batch approach at http://www.mydigitallife.info/2007/05/25/easier-way-to-take-ownership-and-grant-access-files-or-dire…, but it is not for the [...]

  2. christine
    November 5th, 2009 11:10
    18

    is there a command to undo permission changes?

  3. christine
    November 5th, 2009 10:58
    17

    oh yikes. Typed in the commands zephan listed above (with a “.” for current directory — which clearly was not cautious enough of me!).
    Now, I am getting “access denied” messages when I attempt to start any programs (they were fine before). The files with screwed up permissions that i was trying to fix are still blocking me, too. AHHH… is there a script to undo what I just did?

  4. sherry
    April 29th, 2009 21:08
    16

    I just tried both the cmd method and the type it in method. Neither worked. I still, in the command window, get ERROR: Access is denied.

    I lost access when I re-formatted the external disk. Any other suggestions?

  5. zephan
    April 3rd, 2009 08:12
    15

    THANK YOU! This was a lifesaver. I had over 5000 files to fix.

    TIP: No download needed. Open cmd.exe command prompt As Administrator, then enter following commands in order (replacing %1 with desired path/filename or “.” for current directory):

    takeown /f %1 /r /d y
    icacls %1 /grant administrators:F /t

  6. Chris
    April 1st, 2009 01:55
    14

    This just saved me HOURS. The windows GUI approach had literally been running for over 3 hours, and the script finished the job in about 10 seconds.

  7. Joe Naylor
    January 15th, 2009 10:20
    13

    In my opinion the Take Ownership option on the right-click menu should be recursive anyway. Rather than trying to use the script above, you can fix the right-click option simply by using regedit to edit this key:

    HKEY_CLASSES_ROOT\Directory\shell\runas\command

    Verify the contents look similar to this, and change it to:

    cmd.exe /c takeown /f “%1″ /r /d y && icacls “%1″ /grant administrators:F /t

    All that does is add the “/r” recursion option to the takeown command and “/t” option to icacls, and I included a “/d y” to answer “Yes” to any questions which you can take or leave.

    Of course the registry can be dangerous to meddle in if you’re careless, so just take it slow and make sure you’re editing the right thing.

  8. Tips to Slim Down Vista » My Digital Life
    December 8th, 2008 13:05
    12

    [...] permissions to users’ account for the directories and all sub-folders recursively. Use TakeControlOf command script or add a Take Ownership in right click menu to easily do the [...]

  9. Freddy
    November 30th, 2008 03:10
    11

    Quiero acceder a una carpeta

  10. Bruno
    November 23rd, 2008 08:08
    10

    Thanks for the batch file.

    Just note that it might not work in some locales such as mine (Spanish) due to the “y” value in takeown being “s” instead.

  11. Mike
    June 17th, 2008 22:53
    9

    does anyone run this and it goes on forever?

  12. How to Take Ownership and Full Control Permissions of Files and Folders in Vista » Tip and Trick
    April 24th, 2008 22:09
    8

    [...] two commands have been scripted in Windows command shell batch script that easily perform the task of taking ownership and grant full control permissions to [...]

  13. Delete Undeletable Files in Windows Vista » My Digital Life
    April 24th, 2008 21:59
    7

    [...] can also prepared a Windows shell batch script that automate the process for easy take back the files and folders which is inaccessible and [...]

  14. Jutha
    March 20th, 2008 02:03
    6

    THANK YOU SOOOOOOO MUCH. I was foaming at the mouth after I had to buy a new lappie cuz my old one died and when I thought I had to change permissions on every file by hand I was just fuming. It goes to show that the command line is just the most wonderful and conistent and comforting way to get things done.

  15. » 10 things that can go wrong when you upgrade your operating system | 10 Things | TechRepublic.com
    December 17th, 2007 16:01
    5

    [...] This can also happen with real files and folders if your user account information has changed in the new version of Windows. Or you might be trying to access system files. You may be able to fix the problem by taking ownership of the object. You’ll need to be logged on as an administrator to do that. For more on how this works, see “Easier Way to Take Ownership and Grant Access Files or Directories in Vista.” [...]

  16. Eric J
    October 12th, 2007 00:02
    4

    Or does anyone know of another script like it?

  17. Eric J
    October 12th, 2007 00:01
    3

    The download link for the TakeControlOf.zip is no longer working (at least for me). Has it been taken down?

  18. How to Take Ownership and Grant Permissions in Windows Vista » My Digital Life
    May 31st, 2007 04:50
    2

    [...] to take ownership and grant full control permissions from command line. Or you can also prepare a Windows shell batch script that easily perform the task by typing simple command. Get help or contribute tips or tricks at My [...]

  19. lord death 202
    May 25th, 2007 16:07
    1

    great tip to hack

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.

New Articles

Incoming Search Terms for the Article

take ownership vista - unable to set new owner access is denied - take ownership and grant full access permission - take ownership command line - icacls access is denied - take ownership script - take ownership download - unable to set new owner - windows change file owner command line - access is denied vista system32 - remove ownership vista - how to grant full access permission in vista - takecontrolof.zip - WINDOWS VISTA UNABLE TO SET NEW OWNER ACCESS DENIED - how to get full access in vista - icacls access denied - takeown access denied - vista take ownership - windows change owner command line - vista ownership and grant full access permission - TakeControlOf.zip - access denied command line - icacls change owner - ownership and grant full access permission vista - TakeControlOf.zip - unable to set new owner access denied - access files vista - change file ownership vista - command line to change ownership vista\ - file ownership vista - unable to take ownership of a file in windows 7 - change owner vista command line - vista system32 access denied - Windows 2008 R2 system32 access is denied - application to take ownership vista - change files owner windows vista software - change file owner command line - take ownership of a file - vista take ownership and grant full access permission - vista take ownership utility - "take ownership" "access is denied' - change ownership privileges termsrv.dll vista ultimate - download TakeControlOf.zip - how to change permissions vista command line - how to become a owner of a file in vista - takeown batch - taking ownership of a unix file in windows - windows Unable to display current owner. - windows 2008 access denied when trying to take ownership - at.exe grant access -