如何在Windows中使用命令行向用户授予目录权限? [英] How to grant permission to users for a directory using command line in Windows?

查看:430
本文介绍了如何在Windows中使用命令行向用户授予目录权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Windows命令行向用户授予目录(读取,写入,修改)的权限?

解决方案

从Vista开始,不推荐使用 cacls 。这是第一批帮助热线:

  C:\> cacls 
注意:Cacls现在已弃用,请使用Icacls。

显示或修改文件

的访问控制列表(ACL)使用 icacls 代替。这是授予John完全控制 D:\test 文件夹及其所有子文件夹的方式:

  C:\> icacls D:\test / grant John:(OI)(CI)F / T 

根据MS文档进行>


  • F =完全控制

  • CI = Container Inherit-此标志指示从属容器将继承此ACE。

  • OI =对象继承-此标志指示从属文件将继承ACE。

  • / T =递归地应用于现有文件和子文件夹。 ( OI CI 仅适用于新文件和子文件夹)。信用:@AlexSpence提供的评论。



有关完整的文档,您可以运行 icacls (不带参数),或参见Microsoft文档此处此处


How can I grant permissions to a user on a directory (Read, Write, Modify) using the Windows command line?

解决方案

As of Vista, cacls is deprecated. Here's the first couple of help lines:

C:\>cacls
NOTE: Cacls is now deprecated, please use Icacls.

Displays or modifies access control lists (ACLs) of files

You should use icacls instead. This is how you grant John full control over D:\test folder and all its subfolders:

C:\>icacls "D:\test" /grant John:(OI)(CI)F /T

According do MS documentation:

  • F = Full Control
  • CI = Container Inherit - This flag indicates that subordinate containers will inherit this ACE.
  • OI = Object Inherit - This flag indicates that subordinate files will inherit the ACE.
  • /T = Apply recursively to existing files and sub-folders. (OI and CI only apply to new files and sub-folders). Credit: comment by @AlexSpence.

For complete documentation, you may run "icacls" with no arguments or see the Microsoft documentation here and here

这篇关于如何在Windows中使用命令行向用户授予目录权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆