Why Windows prompts for access denied when deleting files

Source: Internet
Author: User
Tags inheritance parent directory valid file permissions


With Windows's small partners must have encountered such a situation, delete files when the prompt file access is denied require the rights provided by XXX to make changes to this file. For the average person, the first thing to do is the right mouse button--Force Delete ... The estimated use of  or other similar software students are not many, visual inspection of this method should be able to delete these files. If your right-click menu does not have this option, you may be able to use other tools that can force the deletion of files, not in this article



In my opinion, the more general way to do this is to change file permissions, right-click File-Properties--security--edit. Modify file permissions, if prompted to modify the permissions, first modify the file owner, right-click File-Security-advanced-owner ... However, when there is more than one such file, this operation is not real. So a brief introduction to two tools: Takeown and cacls



Takeown allows the administrator to regain access to the file that was previously denied access in a way that assigns file ownership.



Parameters:



/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 the file name or directory name pattern. You can specify a pattern with the wildcard character "*". The share name file name is allowed.



/A assigns ownership to the Administrators group, not the current user.



/R recursion: Indicates that the tool is running on a file in the specified directory and sub-directory.



/d Prompt The default answer is used when the current user does not have the "List Folders" permission in a directory. This happens when a recursive (/R) operation is performed in a subdirectory. Take ownership with a valid value of "Y" or skip with "N".



Here are a few common examples



takeown/f lostfile:: Lostfile ownership to the current user



takeown/f directory/r/A:: Recursive way to file all permissions in directory directory to the Administrators group



TAKEOWN/F *:: Ownership of all files in the current directory to the current user



takeown/f%windir%*.txt



cacls the access control list used to display or modify files.



Parameters:



CACLS filename [/T] [/M] [l] [/S[:SDDL]] [/E] [/C] [/g user:perm]



[/R user [...]] [/P User:perm [...]] [/d User [...]]



FileName Displays the ACL.



/T Changes the ACL of the specified file in the current directory and all its subdirectories.



/L handle symbolic link itself against target



/M Changes the ACL of the volume mounted to the directory



/S The SDDL string that displays the DACL.



/S:SDDL replaces the ACL with the ACL specified in the SDDL string. (/E,/g,/r,/p or/d are not valid).



/e Edit the ACL without replacing it.



/C Continue when an Access denied error occurs.



/g User:perm gives the specified user access rights.



Perm can be: R read



W Write



C Change (write)



F Full Control



/r user revokes the access rights of the specified user (only valid when used with/E).



/P User:perm replaces the access rights for the specified user.



Perm can be: N None



R Read



W Write



C Change (write)



F Full Control



/d user denies access to the specified user.



You can use wildcard characters to specify multiple files in a command.



You can also specify multiple users in the command.



Abbreviation:



CI-Container inheritance. The ACE is inherited by the directory.



OI-Object inheritance. Aces are inherited by files.



IO-Inherit only. The ACE does not apply to the current file/directory.



ID-Inherited. Aces inherit from the ACL of the parent directory.



For example:



cacls filename/e/P administrators:f change Administrators access to filename to Full Control



cacls */e/c/P administrators:f change Administrators to Full Control for all file access



With these two commands, you can take ownership of the file in bulk and then delete the file normally



        Note : More Exciting tutorials please follow the Triple computer tutorial section, triple Computer office group: 189034526 Welcome to join


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.