当前位置:文档之家› 文件夹权限的批量修改

文件夹权限的批量修改

如何使用Xcacls.exe 修改NTFS 权限本页∙概要o Xcacls.exe 语法o使用Xcacls.exe 查看权限o Xcacls.exe 示例▪示例1▪示例2▪示例3o NTFS 权限原则∙参考展开全部| 关闭全部本分步指南介绍如何使用扩展的更改访问控制列表工具(Xcacls.exe) 修改和查看文件或文件夹的NTFS 权限。

使用Xcacls.exe 可以通过命令行设置所有可在Windows 资源管理器中访问到的文件系统安全选项。

Xcacls.exe 通过显示和修改文件的访问控制列表(ACL) 完成此操作。

Xcacls.exe 在Windows 2000 Professional 或Windows 2000 Server 的无值守安装中特别有用。

通过使用此工具,可以为操作系统所在的文件夹设置初始访问权限。

在您将软件分发到服务器或工作站时,Xcacls.exe 还提供单步保护,以防止用户删除文件夹或文件。

Xcacls.exe 实用工具包含在Windows 2000 资源工具包中。

可以从Microsoft 下载中心下载以下文件:立即下载XCacls_Installer.exe 软件包。

回到顶端Xcacls.exe 语法xcacls 文件名[/T] [/E] [/C] [/G user:perm;spec] [/R 用户] [/P user:perm;spec [...]] [/D 用户[...]] [/Y]其中文件名表示ACL 或访问控制项(ACE) 通常应用于的文件或文件夹的名称。

所有标准通配符均可使用。

/T递归检查当前文件夹及其所有子文件夹,对匹配的文件或文件夹应用所选的访问权限。

/E编辑ACL 而不替换它。

例如,如果您运行XCACLS test.dat /G Administrator:F命令,则只有管理员拥有对Test.dat 文件的访问权限。

之前应用的所有ACE 都会丢失。

/C使Xcacls.exe 在出现“拒绝访问”错误消息时继续执行。

如果未指定/C,则Xcacls.exe 在出现此错误时停止执行。

/G user:perm;spec授予用户对匹配文件或文件夹的访问权限。

∙perm(权限)变量对文件应用指定的访问权限,并代表文件夹的特殊文件访问权限掩码。

perm变量接受下列值:o R读取o C更改(写入)o F完全控制o P更改权限(特殊访问权限)o O取得所有权(特殊访问权限)o X执行(特殊访问权限)o E读取(特殊访问权限)o W写入(特殊访问权限)o D删除(特殊访问权限)∙spec(特殊访问权限)变量仅应用于文件夹,它除了接受与perm相同的值以外,还接受以下特殊值:o T未指定。

为目录本身设置ACE,而不指定应用于在该目录中创建的新文件的ACE。

至少存在一个要遵循的访问权限。

分号(;) 和T 之间的项将被忽略。

注意:▪文件的访问权限选项(针对文件夹、特殊文件和文件夹访问)是完全相同的。

有关这些选项的详细说明,请参阅Windows 2000 操作系统的文档。

▪所有其他选项(它们也可以在Windows 资源管理器中设置)都是基本访问权限的所有可能组合的子集。

因此,不存在文件夹访问权限(如LIST 或READ)的特殊选项。

/R 用户为指定用户调用所有访问权限。

/P user:perm;spec替换用户的访问权限。

指定perm 和spec 的规则与/G 选项相同。

请参阅本文的“Xcacls.exe 示例”部分。

/D 用户拒绝用户访问文件或目录。

/Y禁止在替换用户访问权限时出现确认提示。

默认情况下,CACLS 要求确认。

由于存在此功能,在批处理例程中使用CACLS 时,例程将停止响应并等待输入正确答案。

引入/Y选项后可消除此确认,从而可以在批处理模式下使用Xcacls.exe。

回到顶端使用Xcacls.exe 查看权限Xcacls.exe 还可用于查看文件或文件夹的权限。

例如,在命令提示符处键入xcacls C:\winnt,然后按Enter。

下面是典型结果:c:\WINNT BUILTIN\Users:RBUILTIN\Users:(OI)(CI)(IO)(special access:)GENERIC_READGENERIC_EXECUTEBUILTIN\Power Users:CBUILTIN\Power Users:(OI)(CI)(IO)CBUILTIN\Administrators:FBUILTIN\Administrators:(OI)(CI)(IO)FNT AUTHORITY\SYSTEM:FNT AUTHORITY\SYSTEM:(OI)(CI)(IO)FBUILTIN\Administrators:FCREATOR OWNER:(OI)(CI)(IO)F这些ACL 标志具有下列含义:∙IO:仅继承—此标志表示此ACE 不应用于当前对象。

∙CI:容器继承—此标志表示从属容器将继承此ACE。

∙OI:对象继承—此标志表示从属文件将继承该ACE。

∙NP:不传播—此标志表示从属对象不继续传播继承的ACE。

每行末尾的字母表示权限。

例如:∙F:完全控制∙C:更改∙W:写入回到顶端Xcacls.exe 示例示例 1在命令提示符下键入XCACLS *.* /G administrator:RW /Y,然后按Enter 以替换当前文件夹中所有文件和文件夹的ACL,而不扫描子文件夹且不进行确认。

示例 2在本示例中,添加到文件夹的ACE 还将继承在此文件夹中创建的新文件的ACE。

该命令授予TestUser 对此文件夹中的所有新建文件的读取、写入、运行和删除权限,但只授予对文件夹本身的读写权限。

在命令提示符下键入XCACLS *.* /G TestUser:RWED;RW /E,然后按Enter。

示例 3下面的示例将授予对文件夹的读写权限,而不为新文件创建继承项。

因此,在本示例中,此文件夹中的新建文件不会收到TestUser 的ACE。

对于现有文件,将创建具有读取权限的ACE。

在命令提示符下键入XCACLS *.* /G TestUser:R;RW /E,然后按Enter。

回到顶端NTFS 权限原则下面是分配NTFS 权限的原则:∙使用NTFS 权限控制对文件和文件夹的访问。

∙将权限分配给组而不是单独用户。

∙NTFS 文件权限优先于NTFS 文件夹权限。

∙管理员以及文件或文件夹的所有者控制可为该对象设置的权限。

∙在更改文件夹权限时,应了解服务器上安装的程序。

程序会创建自己的文件夹并打开“允许从父系来的继承权限传播到这个对象”设置。

如果更改了父文件夹中的权限,则这些更改可能会导致程序中出现问题。

警告:请记住,许多文件和文件夹通过继承接收权限。

因此,在您认为只是更改了一个文件夹时,您可能更改了其他更多内容。

如何使用Xcacls.vbs 修改NTFS 权限Microsoft 以Microsoft Visual Basic 脚本(Xcacls.vbs) 的形式提供了Extended Change Access Control List(扩展更改访问控制列表)工具(Xcacls.exe) 的更新版本。

本文分步介绍如何使用Xcacls.vbs 脚本修改和查看文件或文件夹的NTFS 文件系统权限。

可以从命令行使用Xcacls.vbs 设置所有可在Microsoft Windows 资源管理器中访问的文件系统安全选项。

Xcacls.vbs 可显示和修改文件的访问控制列表(ACL)。

注意:Xcacls.vbs 只与Microsoft Windows 2000、Microsoft Windows XP 和Microsoft Windows Server 2003 兼容。

Microsoft 不支持Xcacls.vbs。

回到顶端设置和使用Xcacls.vbs要设置和使用Xcacls.vbs,请按照下列步骤操作:1.从以下Microsoft 网站获得Xcacls.vbs 的最新版本:/download/f/7/8/f786aaf3-a37b-45ab-b0a2-8c8 c18bbf483/XCacls_Installer.exe2.双击“Xcacls_Installer.exe”。

当提示您提供放置提取文件的位置时,请指定一个位于计算机的搜索路径设置中的文件夹(如C:\Windows)。

3.将默认脚本引擎从Wscript 更改为Cscript。

(Xcacls.vbs 脚本最适合在Cscript 下运行。

)为此,请在命令提示符下键入以下内容,然后按Enter:cscript.exe /h:cscript注意:将默认脚本引擎更改为Cscript 只影响脚本向屏幕写入的方式。

Wscript 根据“确定”对话框分别写入每一行。

Cscript 将每一行写入命令窗口。

如果您不想更改默认脚本引擎,则必须使用以下命令运行脚本cscript.exe xcacls.vbs但是,如果将默认脚本更改为Cscript,则可以使用以下命令运行该脚本:xcacls.vbs.4.要查看Xcacls.vbs 的命令语法,请在命令提示符处键入下面的命令:xcacls.vbs /?Xcacls.vbs 命令的语法下面xcacls.vbs /?命令的输出描述了Xcacls.vbs 命令的语法:Usage:XCACLS filename [/E] [/G user:perm;spec] [...] [/R user [...]] [/F] [/S] [/T][/P user:perm;spec [...]] [/D user:perm;spec] [...][/O user] [/I ENABLE/COPY/REMOVE] [/N[/L filename] [/Q] [/DEBUG]filename [Required] If used alone, it displays ACLs.(Filename can be a filename, directory name orwildcard characters and can include the wholepath. If path is missing, it is assumed to beunder the current directory.)Notes:- Put filename in quotes if it has spaces orspecial characters such as &, $, #, etc. - If filename is a directory, all files andsubdirectories under it will NOT be changedunless the /F or S is present./F [Used with Directory or Wildcard] This will change allfiles under the inputted directory but will NOTtraverse subdirectories unless /T is also present.If filename is a directory, and /F is not used, nofiles will be touched./S [Used with Directory or Wildcard] This will change allsubfolders under the inputted directory but will NOTtraverse subdirectories unless /T is also present.If filename is a directory, and /S is not used, nosubdirectories will be touched./T [Used only with a Directory] Traverses eachsubdirectory and makes the same changes. This switch will traverse directories only if thefilename is a directory or is using wildcard characters./E Edit ACL instead of replacing it./G user:GUI Grant security permissions similar to Windows GUIstandard (non-advanced) choices./G user:Perm;Spec Grant specified user access rights. (/G adds to existing rights for user)User: If User has spaces in it, enclose it in quotes.If User contains #machine#, it will replace#machine# with the actual machine name if it is anon-domain controller, and replace it with theactual domain name if it is a domain controller.New to 3.0: User can be a string representingthe actual SID, but MUST be lead by SID#Example:SID#S-1-5-21-2127521184-160...(SID string shown has been shortened)(If any user has SID# then globally allmatches must match the SID (not name)so if your intention is to apply changesto all accounts that match Domain\Userthen do not specify SID# as one of theusers.)GUI: Is for standard rights and can be: Permissions...F Full controlM ModifyX read and eXecuteL List folder contentsR ReadW WriteNote: If a ; is present, this will be considereda Perm;Spec parameter pair.Perm: Is for "Files Only" and can be: Permissions...F Full controlM ModifyX read and eXecuteR ReadW WriteAdvanced...D Take OwnershipC Change PermissionsB Read PermissionsA Delete9 Write Attributes8 Read Attributes7 Delete Subfolders and Files6 Traverse Folder / Execute File5 Write Extended Attributes 4 Read Extended Attributes 3 Create Folders / Append Data2 Create Files / Write Data 1 List Folder / Read DataSpec is for "Folder and Subfolders only" and has thesame choices as Perm./R user Revoke specified user's access rights. (Will remove any Allowed or Denied ACL's for user.)/P user:GUI Replace security permissions similar to standard choices./P user:perm;spec Replace specified user's access rights.For access right specification see /G option.(/P behaves like /G if there are no rights set for user.)/D user:GUI Deny security permissions similar to standard choices./D user:perm;spec Deny specified user access rights. For access right specification see /G option.(/D adds to existing rights for user.)/O user Change the Ownership to this user or group./I switch Inheritance flag. If omitted, the default is to not touchInherited ACL's. Switch can be:ENABLE - This will turn on the Inheritance flag ifit is not on already.COPY - This will turn off the Inheritance flag andcopy the Inherited ACL'sinto Effective ACL's.REMOVE - This will turn off the Inheritance flag andwill not copy the Inherited ACL's. This is the opposite of ENABLE.If switch is not present, /I will be ignored andInherited ACL's will remain untouched./L filename Filename for Logging. This can include a path nameif the file is not under the current directory.File will be appended to, or created if it does notexit. Must be Text file if it exists or error will occur.If filename is omitted, the default name of XCACLS willbe used./Q Turn on Quiet mode. By default, it is off.If it is turned on, there will be no display to the screen./DEBUG Turn on Debug mode. By default, it is off. If it is turned on, there will be more informationdisplayed and/or logged. Information will showSub/Function Enter and Exit as well as other importantinformation./SERVER servername Enter a remote server to run script against./USER username Enter Username to impersonate for Remote Connections(requires PASS switch). Will be ignored if it is for a Local Connection./PASS password Enter Password to go with USER switch (requires USER switch).Wildcard characters can be used to specify more than one file in a command, such as:* Any string of zero or more characters? Any single characterYou can specify more than one user in a command.You can combine access rights.使用Xcacls.vbs 查看权限Xcacls.vbs 还可用于查看文件或文件夹的权限。

相关主题