The takeown tool allows administrators to regain access to files that were previously denied access in a way that redistributes file ownership,
takeown [/s system [/u username [/p [password]]]]]
/f filename [/a] [/r [/d prompt]]
This tool allows administrators to regain access to files that were previously denied access by reassigning file ownership.
/s system Specifies the remote system to connect to.
/u [domain \] user specifies the user context,The command executes in this context.
/p [password] Specifies the password for the given user context.If omitted,
Prompt for input.
/f filename Specifies a file or directory name pattern.You can use the wildcard "*"
Specify the mode.Allow share name \ file name.
/a gives ownership to the admins group,Not the current user.
/r recursive:instructs the tool to run in the specified directory and subdirectories
On the file.
/d prompt Use the default answer if the current user does not have "list folders" permission in a directory.When done in a subdirectory
This happens during recursive (/r) operations.Take ownership with valid value "y" or skip with "n".
/?Display this help message.
Note:1) If/a is specified, file ownership is given to the currently logged in user.
2) Mixed mode of "?" and "*" is not supported.
3)/d suppresses confirmation prompts.
takeown/f \\ system \ share \ lostfile/a
takeown/f directory/r/d n
takeown/f c:\ windows \ system32 \ acme.exe
takeown/f%windir%\ *. txt
takeown/s system/f myshare \ acme * .doc
takeown/s system/u user/f myshare \ foo.dll
takeown/s system/u domain \ user/p password/f share \ filename
takeown/s system/u user/p password/f doc \ report.doc/a
takeown/s system/u user/p password/f myshare \ *
takeown/s system/u user/p password/f home \ logon/r
takeown/s system/u user/p password/f myshare \ directory/r/a
Here are some examples:
Forcibly change the owner of all files and folders and subfolders in the current directory to the administrators command:
takeown/f */a/r/d y
Change the ntfs permissions of all files and subfolders in the d:\ documents directory to only the administrators group (administrators) full control (remove all the original ntfs permission settings):
cacls d:\ documents \ *. */t/g administrators:f
Add the full control permissions of the administrators (administrators) to the ntfs permissions of the files and subfolders in the original d:\ documents directory (do not delete all the original ntfs permission settings):
cacls d:\ documents \ *. */t/e/g administrators:f
Cancel the full control permissions of the administrators group (not delete all the original ntfs permission settings):
cacls \\ server \ documents \%username%\ My Documents/t/e/r "mddq \ domain admins"
cacls \\ server \ documents \%username%\ desktop/t/e/r "mddq \ domain admins"
Through these two commands, you can achieve batch control of folder and file owner permissions and add administrator group full control permissions.
- Automatically modify the bat code of the local IP address
- Bat uses forfiles to automatically delete expired files in batches
- Batch processing perfectly realizes FTP remote backup data
- Batch process to get the number of txt file lines under the folder and add to the file name
- Batch processing to import the file names in File Mania into the corresponding names in the table
- Problems encountered when deleting folders using batch processing
- vbs and bat mixed to modify the volume label of the virtual drive letter
- Guide to using the batch for command
- Bat batch script under Windows using telnet to detect remote ports in batches