Use CACLS Windows NT utility to edit or display file permissions

本文详细介绍了Windows NT系统中用于显示和更改NTFS分区上文件访问控制列表(ACL)的CACLS命令。包括命令的基本用法、参数说明及如何通过批处理文件自动化执行权限变更等高级操作。
CACLS displays or changes access control lists ( ACLs ) of Windows NT files on NTFS partitions. Windows NT security manager uses the ACLs by: <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

·         Checking for any specified No Access for the user or any groups the user is a member of. If No Access is found, the user is denied access.

·         Checking for any specific granting of access based on the service requested for the user and any groups the user is a member of. If access such as Grant is found, the user is granted access. The users rights are the cumulative rights granted to the user's account and the user's groups.

·         If neither a specific No Access nor service permission is found, the default of No Access applies. Therefore, the user is denied access.

If you have the Windows Resource Kit it includes an enhanced version named XCACLS which takes the same parameters and has additional capabilities. If you have a few bucks, and its well worth the price, www.trustedsystems.com offers SuperCACLs which has superior features to the Microsoft utilities. Its a maxim but true, you get what you pay for. If you do not have the resource kit, cacls comes with Windows NT.

CACLS filename [/T] [/E] [/C] [/G user:perm] [/R user [...]] [/P user:perm [...]] [/D user [...]]

where

/T Changes ACLs of specified files in the current directory and subdirectories
/E Edit ACL instead of replacing it
/C Continue (ignore) access denied errors
/G user : perm where access rights granted can be: R C F (read, change, full control)
/R user Revoke specified user's access rights (only valid with /E)
/P user : perm Replace specified user's access rights. Permission can be: N R C F (none, read, change, ful control)
/D user Deny specified user access.

You simply can not beat this kind of commandline utility for automating changes which are simply too labor intensive using the GUI tools. SYSTEM should have access to all of NTFS. You can reapply this by running at root of drive:

CACLS * /e /t /g SYSTEM:F

where the /e switch tells the CACLS utility to EDIT the ACLs rather than REPLACE the existing permissions, and the /t switch tells it to apply the edit to subdirectories.

If you run CACLS and see the message:

Unable to perform a security operation on an object which has no associated security

you are running on a FAT partition. ACLs are only used on NTFS partitions.

To grant user wmaples full control over myfile.txt:

cacls c:\myfile.txt /G wmaples:F

All other previously defined permissions will be deleted. If you don't want to remove previously defined permissions, add the /E switch:

cacls c:\myfile.txt /E /G wmaples:F

Adds user wmaples to the security permissions of the file, but other permissions are left unchanged. To use Cacls.exe in batch files you need to handle the Are you Sure? prompt. If you try to replace all the security permissions for a file without using the /E switch, Cacls.exe will display the Are You Sure? (Y/N) prompt. To successfully script this in a batch file, you'll have to run the command as:

echo y| cacls c:\myfile.txt /G wmaples:F

Note the echo y| in front of the command: Make sure you don't put a space between | and y.

To get the listing of all parameters, run:

cacls /?

转载于:https://www.cnblogs.com/Qia_sky/archive/2006/01/04/311099.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值