TONT 42353 为何文件夹的『只读』属性表现如此诡异?

特别的爱给特别的你。

原文链接:https://blogs.msdn.microsoft.com/oldnewthing/20030930-00/?p=42353

It’s actually a signal to Explorer to look harder. It doesn’t mean that the directory is read-only.

实际上(文件夹的只读属性)只是让资源管理器再仔细看看文件夹的内容,并不意味着这个文件夹是只读的。

If a folder has the Readonly or System flag set, then Explorer will look for a desktop.ini file which describes the folder customizations. For performance reasons, Explorer does this only if the directory has the +R or +S flag. (This is enormously important on slow networks.)

如果某个文件夹设置了『只读』或『系统』属性,Explorer就会在该文件夹下查找desktop.ini,该文件用于描述文件夹的自定义设置。出于对性能的考虑,资源管理器只会对设置了『只读』或『系统』属性的文件夹这么做。(这在慢速网络上是极其重要的。)

There are two KB articles on this subject, and I will defer to them for much of the discussion. This is the version that applies to Windows XP and Windows Server 2003. There is also a version that applies to older versions of Windows, although the UseSystemForSystemFolders policy still applies.

有两篇知识库文章解说了这个话题,这里我将他们搬出来作为详细的解释。这篇是针对Windows XP和Windows Server 2003的还有一个版本是针对旧版Windows的(译注:该链接已失效),虽然其中有关UseSystemForSystemFolders的策略仍然有效。

Coders shold use the function PathMakeSystemFolder to mark a folder as requiring special attention from Explorer.

如果需要资源管理器的特别关照,程序员们应当(译注:shold原文如此)使用PathMakeSystemFolder对文件夹进行标记。

(译后:只看上面的文章可能对作者想说什么一头雾水,以下为文中提及的KB文章的译文)

You cannot view or change the Read-only or the System attributes of folders in Windows Server 2003, in Windows XP, in Windows Vista or in Windows 7

在Windows Server 2003、Windows XP、Windows Vista和Windows7中,无法对文件夹的『只读』或『系统』属性进行查看或更改

SUMMARY/摘要

This article contains step-by-step instructions on how to use the Attrib command to work around the inability to view or to remove the Read-only or the System attributes of folders in Windows Server 2003, in WindowsXP, Windows Vista and in Windows 7.

本文包含对如何使用Attrib命令对包含『只读』或『系统』属性的文件夹的这两种属性进行查看或移除的指导,作为对在图形界面下该功能缺失的替代方案,适用于Windows Server 2003、WindowsXP、Windows Vista和Windows 7。

This article is intended for advanced computer users.

本文目标群体为对计算机有深入了解的用户。

Symptoms of the problem/问题梗概

You may experience any of the following symptoms:

用户可能遇到如下情况:

You cannot view or change the Read-only or System attributes of a folder by using the Properties dialog box for the folder. For example, you may experience the following symptoms:

一、无法使用『属性』对话框对文件夹的『只读』或『系统』属性进行更改。例如,用户可能会遇到如下情况:

When you view the General tab of a folder’s Properties dialog box, the Read-only check box is not available, and there is no check box to change the System attribute.

1、文件夹的『属性』对话框中,『常规』选项卡下不包含『只读』属性的检查框(Checkbox),也没有可以对『系统』属性进行修改的检查框。

You click to clear or click to select the Read-only check box on the General tab of a folder’s Properties dialog box. When you click OK or Apply, you receive the following message:

2、在文件夹『属性』对话框的『常规』选项卡下,用户选中或取消选中『只读』属性前的检查框。当单击『确定』或『应用』按钮时,会收到如下的信息:

Confirm Attribute Changes/确认属性更改
You have chosen to make the following attribute changes:/您已选择对属性进行如下更改:
unset read-only/取消『只读』
Do you want to apply this change to this folder only, or do you want to apply it to all subfolders and files as well?/是否要将此更改仅应用于此文件夹,或者是否要将它应用于所有子文件夹和文件?

If you click Apply changes to this folder only, the Read-only attribute is changed for all the files in the folder. However, the Read-only attribute is not changed for the folder, its subfolders, or any files in its subfolders. If you click Apply changes to this folder, subfolders, and files, the Read-only attribute is changed for all files in the folder and all files in the subfolders. However, the Read-only attribute is not changed for the folder or its subfolders.

如果选择『仅应用于此文件夹』,则『只读』属性的修改(译注:由于上文提到的是『选中或取消选中只读属性』,所以这里可能是设置只读属性,也可能是取消只读属性,下同)将应用于文件夹下(第一级内)的所有文件,但是,文件夹本身的『只读』属性不会发生变化,其所包含的子文件夹、以及子文件夹下的任何文件的『只读』属性也不会改变。如果选择『应用于所有子文件夹和文件』,则『只读』属性的修改会应用于该文件夹、及该文件夹内包含的子文件夹中的所有文件,但是,不会应用于该文件夹本身即其包含的子文件夹本身。

Some programs may display error messages when you try to save files to a folder that uses the Read-only or System attribute. As a result, these programs may not be able to save files to the folder.

部分应用程序可能会在尝试将文件保存至包含只读属性的文件夹时报错,由此,这些应用程序可能无法将文件保存至这些文件夹。

Cause/原因分析

Note Unlike the Read-only attribute for a file, the Read-only attribute for a folder is typically ignored by Windows, Windows components and accessories, and other programs. For example, you can delete, rename, and change a folder with the Read-only attribute by using Windows Explorer.

与文件的『只读』属性不同,文件夹的『只读』属性通常被Windows、Windows组件、附件及其它应用程序所忽略。例如,你可以通过资源管理器对已设置了『只读』属性的文件夹进行删除、重命名,或对其中的内容进行修改。

The Read-only and System attributes is only used by Windows Explorer to determine whether the folder is a special folder, such as a system folder that has its view customized by Windows (for example, My Documents, Favorites, Fonts, Downloaded Program Files), or a folder that you customized by using the Customize tab of the folder’s Properties dialog box. As a result, Windows Explorer does not allow you to view or change the Read-only or System attributes of folders. When a folder has the Read-Only attribute set it causes Explorer to request the Desktop.ini of that folder to see if any special folder settings need to be set. It has been seen where if a network share that has a large amount of folders set to Read-only, it can cause Explorer to take longer then what is expected to render the contents of that share while it waits on the retrieval of the Desktop.ini files. The slower the network connectivity to the share the longer this process can take to the point where Explorer may timeout waiting for the data and render nothing or appear to hang.

『只读』和『系统』属性被资源管理器用作判断某个文件夹是否是特殊的文件夹的条件,比如一些被Windows特别定义过视图的系统文件夹(例如:我的文档、收藏夹、字体、已下载的程序文件(Downloaded Program Files,译注:这是被Internet Explorer调用的一个特殊文件夹,用于存储下载的ActiveX控件等等)),或者被用户在『属性』对话框中用『自定义』功能修改过的文件夹。因此,Windows资源管理器不允许用户修改文件夹的『只读』和『系统』属性。当一个文件夹设置了『只读』属性,资源管理器会查找其中的Desktop.ini以了解是否有特别的文件夹设置。曾有事例表明,在网络共享中如果有一大堆只读文件夹,资源管理器会比平常花更多的时间渲染该共享中的内容,因为资源管理器花了很多时间去检索和获取其中的Desktop.ini文件。网络连接的速度越慢,这个过程就越花费时间,资源管理器有可能最终等待超时,并将该共享文件夹(错误地)描绘为空无一物,或看上去就像死机了一样。

Note In some previous versions of Windows, you can change the Read-only attribute for folders by using the Properties dialog box for the folder, but no versions of Windows permit you to change the System attribute by using Windows Explorer.

需注意的是,在早期的若干Windows版本中,用户仍可使用文件夹的『属性』对话框修改其『只读』属性,但不存在任何一个版本的Windows允许使用资源管理器修改其『系统』属性。

Steps to work around this problem/解决此问题的替代方案

To work around this problem, use the Attrib command at a command prompt (Cmd.exe) to view or to remove the Read-only or the System attributes of folders.

为通过替代手段解决此问题,请在命令提示符(Cmd.exe)中使用Attrib命令来查看或移除文件夹的『只读』或『系统』属性。

To view or to remove the Read-only or the System attributes of folders/要移除文件夹的『只读』或『系统』属性,请进行如下操作

Warning If you remove the Read-only or System attribute from a folder, it may appear as a ordinary folder and some customizations may be lost. For example, Windows customizes the Fonts folder and provides a special folder view that permits you to hide variations, such as bold and italic. It also permits you to change the folder’s view settings in ways that are specific to fonts. If you remove the Read-only and System attributes of the Fonts folder, these customized view settings are not available. For folders that you have customized by using the Customize tab of the folder’s
Properties dialog box, the folder icon and other other customizations may be lost when you remove the Read-only attribute.

警告:如果移除文件夹的『只读』或『系统』属性,其将表现为一个普通文件夹,一些自定义设置可能会丢失。例如,Windows为Fonts(字体)文件夹进行了自定义,为其提供了特殊的视图,以便用户可以隐藏字体的变体(以方便查看),如黑体、斜体等。该自定义视图还允许以(不同于普通文件的)字体的特性来修改Fonts文件夹的组织形式。如果用户移除了Fonts文件夹的『只读』和『系统』属性,上述自定义视图选项将不可用。对于使用了『属性』对话框中『自定义』功能进行过定制的文件夹,当移除文件夹的『只读』属性时,自定义的文件夹图标及其它定制设置可能会丢失。

If a program cannot save files to a folder with the Read-only attribute, such as My Documents, change the Read-only attribute to System by using the Attrib command at a command prompt.

如果某应用程序无法将文件保存到具有只读属性的文件夹(如:我的文档),请使用命令提示符中的Attrib命令修改其『只读』属性。

Note If the Run command is not listed on the Start menu, do the following: Click Start, click All Programs, click Accessories, and then click Run.

如果『运行』命令没有在开始菜单中列出,请进行以下操作:单击『开始』按钮,点击『所有程序』,找到『附件』并点击其中的『运行』。(译注:在英文键盘上,按下Win+R也可以)。

To remove the Read-only attribute and to set the System attribute, use the following command:

要移除(文件夹)的『只读』属性并为其添加『系统』属性,使用以下命令:

attrib -r +s drive(驱动器):\<path(路径)>\<foldername>(文件夹名称)

For example, to remove the Read-only attribute and to set the System attribute for the C:\Test folder, use the following command:

例如,要为C盘下的Test文件夹移除『只读』属性并添加『系统』属性,使用以下命令:

attrib -r +s c:\test

Be aware that some programs may not operate correctly with folders for which the System attribute and the Read-only attribute are set. Therefore, use the following command to remove these attributes:

注意:某些应用程序可能无法对(同时)设置了『系统』和『只读』属性的文件夹正常操作。在这种情况下,使用以下指令移除(文件夹的)这些属性:

attrib -r -s c:\test

Status/问题状态

This behavior is by design.

上述情景为人为刻意设计。

More Information/更多信息

Windows stores file and folder attributes in the file system with the file and folder name, extension, date and time stamps, and other information. The Read-only check box for folders is not available because it does not apply to the folder. You can use this check box to set the Read-only attribute for files in the folder. However, you cannot use Windows Explorer to determine whether a folder has the Read-only and System attributes set. To determine the attributes that are set on a folder, or to change these attributes, you must use the Attrib command at a command prompt.

Windows在文件系统中存储文件和文件夹的名称、扩展名、日期和时间戳等信息。『只读』检查框不可见的原因为其不适用于文件夹。用户可使用该检查框来为文件夹中包含的文件设置只读属性,但无法使用Windows资源管理器判定某文件夹是否设置了『只读』和『系统』属性。要获得此信息或修改之,用户必须在命令提示符下使用Attrib命令进行操作。

References/参考资料

For more information about system attributes, click the following article numbers to view the articles in the Microsoft Knowledge Base:

要获取更多关于系统属性的信息,请点击下列文章编号来阅读Microsoft知识库中的文章:

308419 How to set, view, change, or remove special permissions for files and folders in Windows XP

308419 如何在Windows XP中设置、查看、修改文件及文件夹的特殊权限

277867 Windows NTFS permissions are required when you run Word on any NTFS partition that has Windows 2000, Windows XP Professional, Windows Server 2003, or Windows Vista installed

277867 当在安装了Windows 2000、Windows XP Professional、Windows Server 2003或Windows Vista的计算机的NTFS分区上运行Word时,需要获取Windows NTFS权限

If the previous articles do not help you resolve the problem or if you experience symptoms that differ from those that are described in this article, search the Microsoft Knowledge Base for more information. To search the Microsoft Knowledge Base, visit the following Microsoft Web site:

若上述文章未能解决您的问题,或您所遇到的情况与文中所述有异,请在Microsoft知识库中进行检索以获得更多信息。要在Microsoft知识库中进行搜索,请访问以下Microsoft Web站点:

http://support.microsoft.com

Then, type the text of the error message that you receive or type a description of the problem in the Search Support (KB) field.

进入后,在『搜索支持(KB)』文本域中输入您所遇到的错误信息,或输入对问题的描述以进行检索。

Comments

  1. 原本 DOS 下,文件夹是没有属性的。 Windows 是继承 DOS 的概念继续开发的,但不知为何 Windows 文件夹也有属性可以设置。当然 Windows 的权限管理做得一团糟,所以没人当回事。到了 NTFS 文件系统之后微软才正式开始考虑这些遗留问题,当然权限管理依旧做得一团糟。

  2. 9x的权限管理的确一团糟,至于NTFS的权限管理有问题,一定程度上也是因为用户太蠢。

  3. 用户太蠢这个不能否认,不过如果NTFS+AD+WD+SAMBA都加起来一起使用的话你就知道有多Broken了。国内多数用户都蠢,这么用的时候,简直就是蠢蠢联合。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

 剩余字数 ( Characters available )

Your comment will be available after auditing.
您的评论将在通过审核后显示。

Please DO NOT add any links in your comment, otherwise it would be identified as SPAM automatically and never be audited.
请不要在评论中插入任何链接,否则将被自动归类为垃圾评论,且永远不会被提交给博主进行复审。

*