[英]On Windows 10, grant a user rights to create, edit and delete files in the folder C:\VMs, but prevent deletion of the folder itself
我需要用户能够访问和修改文件夹C:\\ VMs中的内容。 我正在使用https://ss64.com/nt/icacls.html作为指南。 在页面底部,有一些命令列表可以完全满足我的需要,但是第一个命令不起作用。
在Powershell中,我输入
icacls.exe "C:\VMware" /inheritance:r /grant:r testuser:(OI) (CI) (F)
并得到错误
The term 'OI' is not recognized as the name of a cmdlet...
我已经尝试过使用不同的间距和引号等进行各种迭代,但是没有任何运气。
问题在于括号在Powershell中具有特殊含义 。 如果要将它们原样传递给外部程序,则必须用引号引起来。 链接到的文章假定您正在使用旧式命令外壳,在这种情况下,它在方括号中没有特殊含义。
进行此工作的一种方法是将反引号用作转义字符:
icacls test /grant Everyone:`(OI`)`(CI`)`(RX`)
由于您正在运行Windows 10,因此可以改为使用停止解析符号 :
icacls test --% /grant Everyone:(OI)(CI)(RX)
停止解析符号需要Powershell 3或更高版本,因此它在Windows 7计算机上不能即用工作,但是在Windows 10上就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.