使用xcacls.vbs(cacls.exe)修改NTFS权限说明(中文版)

2017-03-17 13:39:37  xcacls.vbsNTFS权限

概要
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 的最新版本:
http://download.microsoft-com/download/f/7/8/f786aaf3-a37b-45ab-b0a2-8c8c18bbf483/XCacls_Installer.exe (http://download.microsoft-com/download/f/7/8/f786aaf3-a37b-45ab-b0a2-8c8c18bbf483/xcacls_installer.exe)

XCACLS.vbs直接下载http://xiazai.www.haoshilao.net/201008/tools/XCACLS.rar
2. 双击“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 or
wildcard characters and can include the whole
path. If path is missing, it is assumed to be
under the current directory.)
Notes:
- Put filename in quotes if it has spaces or
special characters such as &, $, #, etc.
- If filename is a directory, all files and
subdirectories under it will NOT be changed
unless the /F or S is present.

/F [Used with Directory or Wildcard] This will change all
files under the inputted directory but will NOT
traverse subdirectories unless /T is also present.
If filename is a directory, and /F is not used, no
files will be touched.

/S [Used with Directory or Wildcard] This will change all
subfolders under the inputted directory but will NOT
traverse subdirectories unless /T is also present.
If filename is a directory, and /S is not used, no
subdirectories will be touched.

/T [Used only with a Directory] Traverses each
subdirectory and makes the same changes.
This switch will traverse directories only if the
filename is a directory or is using wildcard characters.
/E Edit ACL instead of replacing it.

/G user:GUI Grant security permissions similar to Windows GUI
standard (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 a
non-domain controller, and replace it with the
actual domain name if it is a domain controller.

New to 3.0: User can be a string representing
the 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 all
matches must match the SID (not name)
so if your intention is to apply changes
to all accounts that match Domain\User
then do not specify SID# as one of the
users.)

GUI: Is for standard rights and can be:
Permissions...
F Full control
M Modify
X read and eXecute
L List folder contents
R Read
W Write
Note: If a ; is present, this will be considered
a Perm;Spec parameter pair.

Perm: Is for "Files Only" and can be:
Permissions...
F Full control
M Modify
X read and eXecute
R Read
W Write
Advanced...
D Take Ownership
C Change Permissions
B Read Permissions
A Delete
9 Write Attributes
8 Read Attributes
7 Delete Subfolders and Files
6 Traverse Folder / Execute File
5 Write Extended Attributes
4 Read Extended Attributes
3 Create Folders / Append Data
2 Create Files / Write Data
1 List Folder / Read Data
Spec is for "Folder and Subfolders only" and has the
same 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 touch
Inherited ACL's. Switch can be:
ENABLE - This will turn on the Inheritance flag if
it is not on already.
COPY - This will turn off the Inheritance flag and
copy the Inherited ACL's
into Effective ACL's.
REMOVE - This will turn off the Inheritance flag and
will not copy the Inherited
ACL's. This is the opposite of ENABLE.
If switch is not present, /I will be ignored and
Inherited ACL's will remain untouched.

/L filename Filename for Logging. This can include a path name
if the file is not under the current directory.
File will be appended to, or created if it does not
exit. Must be Text file if it exists or error will occur.

If filename is omitted, the default name of XCACLS will
be 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 information
displayed and/or logged. Information will show
Sub/Function Enter and Exit as well as other important
information.

/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 character

You can specify more than one user in a command.
You can combine access rights.==========================================================
青云翻译如下:

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 [要求]如果单独地使用,它显示ACL。
(文件名能是一文件名并且能包括全部道路,目录名字orwildcard性格。
如果道路是丢失的,beunder当前的目录假定的。)
注意到:
- 如果它有诸如的空间或者特殊的性格,将文件名放在行情中 &, $, #, 等等.
- 如果文件名是一个目录,所有文件和在它之下的子目录将不被改变除非与F或者S是出席的.

/F [与目录或者通配符使用]这将改变所有在输入目录之下的文件但是将不横过子目录除非与T是也出席的.
如果文件名是一个目录,和与F将不是加以使用,没有文件将被触到。

/S [与目录或者通配符使用]这将改变所有在输入目录之下的subfolders但是将不横过子目录除非与T是也出席的。
如果文件名是一个目录,和与S将不是加以使用,没有子目录将被触到。

/T [仅仅与一个目录使用]横过每一子目录并且制定同样的改变。
这个开关将横过目录仅当文件名是一个目录或者使用通配符。
/E 编辑ACL而不是替换它。

/G user:GUI 应允类似于Windows GUI的安全允许标准(非先进)的选择。
/G user:Perm;Spec 给予指定用户接近权利。
(/G 为了用户予以添加到现有的权利)

用户: 如果用户在其中有空间,在行情中封入它。
如果用户包含#machine#,它将替换 #带有实际的机器名字的machine#如果它是a 非领域控制器,
并且以替换它实际的域名如果它是一个领域控制器。

对3.0不熟悉: 用户能是串代表实际的SID,但是肯定SID的引导#
例子: SID#S-1-5-21-2127521184-160...
(SID串显示已被缩短)
(如果任何用户有SID#然后在全球所有比赛必须匹配SID (不命名) 那么如果你的意图
是运用改变对于与领域\用户匹配的所有原由然后,不要把SID#不规定成为的一用户。)

图形: 为了标准权利并且能:
权限...
F 完全控制
M 修改
X 读取并且执行
L 列出文件夹内容
R 读取
W 写入
注意: 如果 a ; 是当前的, 这将被考虑
一Perm;Spec参数双。

Perm: 为了“只有文件”并且能:
权限...
F 完全控制
M 修改
X 读取并且执行
R 读取
W 写入
高级的...
D 获取所有权
C 改变允许
B 阅读允许
A 删除
9 写属性
8 读取属性
7 删除子文件夹和文件
6 穿过文件夹 / 执行文件
5 写扩展的属性
4 读取扩展的属性
3 创建文件夹 / 附加数据
2 创建文件 / 写数据
1 列出文件夹 / 读取数据
Spec为了“只有文件夹和子文件夹”并且有作为Perm的同样的选择。

/R user 撤销指定的用户的接近权利。
(将移去ACL为了用户允许或者予以否认的任何。)

/P user:GUI 替换类似于标准的选择的安全允许。

/P user:perm;spec 替换被指定的用户存取权利。
为存取权说明参见/G 选项。
(/P 表现象/G 如果没有权利被设置为用户。)
/D user:GUI 拒绝类似于标准的选择的安全允许。
/D user:perm;spec 拒绝指定的用户接近权利。
为存取权说明参见/G 选项。
(/D 添加在现有的右边为用户。)
/O user 改变所有权到这个用户或组。

/I switch 继承标志。如果省去, 默认值将不接触
被继承的ACL's 。切换可能是:
ENABLE - 如果它已经不打开,这将打开继承标志
COPY - 这将关闭继承标志和将复制被继承的ACL's
到有效的ACL中` s。
REMOVE - 这将关闭继承标志并且将不复制继承的ACL ` s。
这是实现的相反的。
如果切换不是存在, /I 将被忽略并且被继承的ACL's 将保留未触动过。

/L filename 记录的文件名. 如果文件不是在当前的目录下面这可能包括路径名字。
是否它不退出,文件将被附加到,或者创造。如果它存在,肯定正文文件或者差错将发生。

如果文件名被省去, XCACLS 的缺省名将被使用。

/Q 打开安静的方式。缺省,它离开。
如果它被打开,将没有显示到屏幕。


/DEBUG 打开调试方式。缺省,它离开。
如果它打开, 有将是更多信息被显示并且/或者被记录。
信息显示Sub/Function 进入和退出并且其它重要信息。

/SERVER servername 输入一台远程服务器运行脚本针对。

/USER username 进入用户名扮演为远程连接数(要求通过切换) 。将被忽略如果它是为局部连接数。

/PASS password 输入口令连同用户切换
(要求用户切换).


通配符可能被使用指定超过一个文件在一个指令, 譬如:
* 零个或更多字符任何字符串
? 任何单一字符

你能在一种命令中规定超过一个用户。
你能结合接近权利。

==========================================================



使用 Xcacls.vbs 查看权限

Xcacls.vbs 还可用于查看文件或文件夹的权限。 例如,如果您有一个名为 C:\Test 的文件夹,在命令提示符处键入以下命令以查看文件夹权限,然后按 Enter:
xcacls.vbs c:\test
下面的示例是一个典型结果:
C:\>XCACLS.VBS c:\test
Microsoft (R) Windows Script Host 5.6
版权所有 (C) Microsoft Corporation 1996-2001。保留所有权利。

Starting XCACLS.VBS (Version: 3.4) Script at 6/11/2003 10:55:21 AM

Startup directory:
"C:\test"

Arguments Used:
Filename = "c:\test"



**************************************************************************
Directory:C:\test

Permissions:
Type Username Permissions Inheritance

Allowed BUILTIN\Administrators Full Control This Folder, Subfolde
Allowed NT AUTHORITY\SYSTEM Full Control This Folder, Subfolde
Allowed Domain1\User1 Full Control This Folder Only
Allowed \CREATOR OWNER Special (Unknown) Subfolders and Files
Allowed BUILTIN\Users Read and Execute This Folder, Subfolde
Allowed BUILTIN\Users Create Folders / Appe This Folder and Subfo
Allowed BUILTIN\Users Create Files / Write This Folder and Subfo

No Auditing set

Owner:Domain1\User1

注意:在该示例中,xcacls.vbs c:\test 命令的输出与显示在图形用户界面 (GUI) 的文本一致。命令窗口的一些文字不完整。

输出还给出了脚本的版本、启动目录和使用的参数。

您还可以使用通配符来显示目录下匹配的文件。例如,如果键入以下命令,将会显示 C:\Test 文件夹中所有具有“.log”扩展名的文件:
xcacls.vbs c:\test\*.log
示例

下列 Xcacls.vbs 命令提供 Xcacls.vbs 用法的一些示例:

xcacls.vbs c:\test\ /g domain\testuser1:f /f /t /e
该命令可编辑现有权限。它授予 Domain\TestUser1 完全控制 C:\Test 下所有文件的权限,遍历 C:\Test 下的子文件夹,然后更改找到的所有文件。该命令不触及目录。
xcacls.vbs c:\test\ /g domain\testuser1:f /s /l "c:\xcacls.log"
该命令可替换现有权限。它授予 Domain\TestUser1 完全控制 C:\Test 下所有子文件夹的权限,而且记录到 C:\Xcacls.log。该命令不触及文件,并且不遍历目录。
xcacls.vbs c:\test eadme.txt /o "machinea\group1"
该命令将自述文件的所有者更改为组 MachineA\Group1。
xcacls.vbs c:\test\badcode.exe /r "machinea\group1" /r "domain\testuser1"
该命令撤消 MachineA\Group1 和 Domain\TestUser1 的 C:\Test\Badcode.exe 权限。
xcacls.vbs c:\test\subdir1 /i enable /q
该命令将打开文件夹 C:\Test\Subdir1 上的继承。该命令将取消任何屏幕输出。
xcacls.vbs \\servera\sharez\testpage.htm /p "domain\group2":14
此命令通过使用 Windows Management Instrumentation (WMI) 远程连接到 \\ServerA\ShareZ。然后获取用于该共享的本地路径,在该路径下,它更改 Testpage.htm 上的权限。它原封保留 Domain\Group2 的现有权限,但是添加权限 1(读取数据)和权限 4(读取扩展属性)。该命令放弃此文件上的其他权限,原因是未使用 /e 开关。
xcacls.vbs d:\default.htm /g "domain\group2":f /server servera /user servera\admin /pass password /e
该命令使用 WMI 作为 ServerA\Admin 远程连接到 ServerA,然后将 Default.htm 上的完全权限授予 Domain\Group2。Domain\Group2 的现有权限丢失,但保留文件上的其他权限。


参考
有关如何使用 Xcacls.exe 其他信息,请单击下面的文章编号,以查看 Microsoft 知识库中相应的文章:
318754 (http://support.microsoft-com/kb/318754/) 如何使用 Xcacls.exe 修改 NTFS 权限

使用xcacls.vbs(cacls.exe)修改NTFS权限说明(中文版)》阅读地址:http://www.haoshilao.net/14832/

最新图文教程: