You want to take ownership of a file or folder. This may be necessary if you find that NTFS permissions have you locked out of a file or folder. As long as you are an administrator of the system, you should be able to take control of it and reset permissions as necessary.
In the left pane, browse to the parent folder of the file or folder you want to take ownership of. Click on the parent folder. This displays the list of subfolders and files in the right pane.
In the right pane, right-click on the target file or folder and select Properties.
Select the Security tab.
Click the Advanced button.
Select the Owner tab.
Under the Change owner to heading select the new owner and click Apply.
> takeown d:\iwanna.exe
> subinacl /file
> subinacl /file \\rallen-svr1\docs\guide.doc /setowner=AMER\rallen
Or you can even grant ownership to a user over all the files in a directory:
> subinacl /subdirectories \\rallen-svr1\docs\* /setowner=AMER\rallen
' This code transfers ownership of the specified file to the ' user running the script. If strFile is set to a folder path ' then ownership of all files within the folder will be changed. ' ------ SCRIPT CONFIGURATION ------ strFile = "
<FilePath>" ' e.g., d:\scripts strComputer = "
<ServerName>" ' e.g., rallen-svr1 or . for local server ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set objFile = objWMI.Get("CIM_DataFile.Name='" & strFile & "'") intRC = objFile.TakeOwnership if intRC = 0 then WScript.Echo "File ownership successfully changed" else WScript.Echo "Error transferring file ownership: " & intRC end if
If you are taking ownership of a file or folder because you were locked out of it, even after you take ownership you still have to go in and grant yourself the necessary NTFS permissions to access and manipulate the file or folder.
With Windows Explorer on Windows 2000, you can only assign one of the members of the local administrators group as an owner of a file or folder. With Windows Server 2003, there is a new button called Other Users or Groups that lets you use the object picker to select any user as an owner.