Question about read-only attribute


  1. Posts : 24
    Windows 7 Starter 32bit
       #1

    Question about read-only attribute


    I don't use the recycle bin, but have set the read-only attribute for a few of my files, hoping to protect them from accidental deletion. Windows 7 always allows me to delete them anyway, whereas trying that from the command prompt results in the "access denied" message, which is what I'd expect. Can anyone explain this inconsistency, and is there any way to force Windows 7 to respect the read-only attribute (for all files with that attribute, not just particular ones)?
      My Computer


  2. Posts : 2,468
    Windows 7 Ultimate x64
       #2

    The read-only attribute is an obsolete thing of the past, a leftover from DOS, pretty much like all file attributes.

    Nowadays, Windows doesn't pays any attention or does anything special for it, it behaves almost the same (I know of only one exception where Windows changes behavior based on the attribute, and still have my doubts). However, individual programs might take care of it, as you have noted, cmd's refuses to delete such a file, giving a fake "access denied" message. Consider this a coincidence rather than a rule.

    Use, instead, the proper tool for the job. Use the real file access permissions and deny your own account permission to delete the affected file, so that the restriction is enforced by the kernel itself. Or, to prevent accidental deletion, the right thing to do is to make a backup (the recycle bin could be a rudimentary form of backup).

    The attribute doesn't give any security at all and is ignored by almost everything. You could as well forget that it exists, as software most likely won't pay attention to it.
      My Computer


  3. Posts : 24
    Windows 7 Starter 32bit
    Thread Starter
       #3

    Alejandro85 said:
    The read-only attribute is an obsolete thing of the past, a leftover from DOS, pretty much like all file attributes.

    Nowadays, Windows doesn't pays any attention or does anything special for it, it behaves almost the same (I know of only one exception where Windows changes behavior based on the attribute, and still have my doubts). However, individual programs might take care of it, as you have noted, cmd's refuses to delete such a file, giving a fake "access denied" message. Consider this a coincidence rather than a rule.
    One thing that the attribute does accomplish, however, is that the files usually can't be overwritten by the Save command when they've been modified in editing software, such as image or text editors. It brings up an error message.

    ... to prevent accidental deletion, the right thing to do is to make a backup (the recycle bin could be a rudimentary form of backup).
    It's not that big a problem anyway, since I do back up files to my external hard drive from time to time, but I was just curious about read-only, having spent lots of time with DOS in the past (ancient history).

    Actually, read-only files have another slight advantage: I use a third-party file manager, and one of its features is the ability to color-code files by type or attribute. I've selected red for my read-only files, so at least that's a warning to clumsy old me when I'm either tired or in too much of a hurry. :)
      My Computer


  4. Posts : 2,468
    Windows 7 Ultimate x64
       #4

    LowStrung said:
    One thing that the attribute does accomplish, however, is that the files usually can't be overwritten by the Save command when they've been modified in editing software, such as image or text editors. It brings up an error message.
    It depends on each software, programs decide what to do with the attribute, or if even look at it at all. Consider this a coincidence rather than a rule, and don't expect that the simple attribute will protect anything against accidental changes.
    As far as I know, at least notepad and paint honor it. Any other program, I don't know.


    LowStrung said:
    It's not that big a problem anyway, since I do back up files to my external hard drive from time to time, but I was just curious about read-only, having spent lots of time with DOS in the past (ancient history).
    Good to know, that'll be your first line of defense if something goes wrong.
    In the "ancient" times, it used to have some more relevance, and most uses right now are likely leftovers from migrations from DOS programs (like cmd.exe inherited it from command.com). Nowadays, it could as well disappear and nothing would change.


    LowStrung said:
    Actually, read-only files have another slight advantage: I use a third-party file manager, and one of its features is the ability to color-code files by type or attribute. I've selected red for my read-only files, so at least that's a warning to clumsy old me when I'm either tired or in too much of a hurry. :)

    Nice use. Each program does whatever it likes with it. At least it has some useful utility.
      My Computer


  5. Posts : 24
    Windows 7 Starter 32bit
    Thread Starter
       #5

    Alejandro85 said:
    In the "ancient" times, it used to have some more relevance, and most uses right now are likely leftovers from migrations from DOS programs (like cmd.exe inherited it from command.com).
    I'm glad some of the old DOS functionality still exists, because I write lots of batch files. One of them selectively cleans up after programs that don't clean up after themselves. The disk cleanup provided by Windows doesn't provide for that, and the 3rd-party cleanup programs are not flexible enough to find various temporary files from lesser-known applications, esp. if they're portable.

    I'm even fussy enough to include commands for restoring some of my program settings that a program modifies during a session. These are generally .ini files located in the application folders of portable programs. I keep the originals in subfolders, and the batch file uses them to overwrite the modified versions. If the settings are stored in the registry, I back up the registry keys, and import those .reg files back into the registry.

    It's this flexibility that keeps me from upgrading my OS. I've been using Windows 7 since 2011, and intend to keep using it as long as possible.
      My Computer


  6. Posts : 4,049
    W7 Ultimate SP1, LM19.2 MATE, W10 Home 1703, W10 Pro 1703 VM, #All 64 bit
       #6

    LowStrung said:
    I don't use the recycle bin, but have set the read-only attribute for a few of my files, hoping to protect them from accidental deletion. Windows 7 always allows me to delete them anyway, whereas trying that from the command prompt results in the "access denied" message, which is what I'd expect. Can anyone explain this inconsistency, and is there any way to force Windows 7 to respect the read-only attribute (for all files with that attribute, not just particular ones)?
    This is one of the few gripes I have with W7.
    I even wrote to Ed Bott about it during the W7 betas.

    Just before W7 was released, I was training people on how to use XP and Office.
    XP would generate an additional warning if you tried to change/delete a "Read-only" file.
    I suggested to the students that they should set the "Read-only" attribute on their files to prevent accidental deletion.

    With the exception of FreeCommander (file manager) my other software complains if you try to change/delete a "Read-only" file.

    Alejandro85 said:
    Use, instead, the proper tool for the job. Use the real file access permissions and deny your own account permission to delete the affected file, so that the restriction is enforced by the kernel itself.
    The trouble is:

    • It takes more steps to step up and more steps to disable
    • If you have multiple accounts you have to do it to every account
    • Unskilled users might accidentally change the wrong permission(s)

    IMO, the "obsolete" method was better for ordinary users.
    There was only one checkbox to toggle and it affected all users.

    That said, in a business setting changing the Security Permissions would be better, as it would prevent anyone without the proper Access Rights from changing the file permissions and then deleting something they shouldn't.
      My Computer


  7. Posts : 24
    Windows 7 Starter 32bit
    Thread Starter
       #7

    lehnerus2000 said:
    With the exception of FreeCommander (file manager) my other software complains if you try to change/delete a "Read-only" file.
    I use XYplorer (the free edition) as my default file manager. Deletions bring up the standard Windows Explorer delete confirmation. If I try to delete a read-only file, I'm asked to confirm it, but without any mention of the read-only attribute.

    Recently I tried an experiment: I set both the read-only and the system attribute for an unimportant file. On deleting it, I got a warning about the system attribute, but access was not denied; I was allowed to delete the file anyway.

    lehnerus2000 said:
    IMO, the "obsolete" method was better for ordinary users.
    There was only one checkbox to toggle and it affected all users.
    Windows 7 dialogs often ask too many questions. If I want to set the read-only attribute for a folder, I'm asked whether to apply that to the files within it, as well. Most of the time that's not what I want. If I wanted to apply it to the files, I'd go into the folder, select the files and apply the attribute to my selection.

    The copy, move and replace dialogs are also far too wordy, but that's another matter, which is why I use a 3rd-party file manager instead of Windows Explorer.
      My Computer


  8. Posts : 4,049
    W7 Ultimate SP1, LM19.2 MATE, W10 Home 1703, W10 Pro 1703 VM, #All 64 bit
       #8

    I use XYplorer (the free edition) as my default file manager. Deletions bring up the standard Windows Explorer delete confirmation. If I try to delete a read-only file, I'm asked to confirm it, but without any mention of the read-only attribute.
    Currently I have FreeCommander XE set to behave the same as Windows Explorer.
    The behaviour can be changed using options in "Settings > File/folder operations".

    If I change the setting to "Use FreeCommander":

    • Using the "Delete" key or toolbar button generates an additional options window and a warning if I then try to delete a "Read-only" file
    • Using the context menu "Delete" option, it still behaves the same as Windows Explorer

    Question about read-only attribute-fc-xe-file-folder-operations.png
    I wouldn't be surprised if XYplorer has similar options somewhere. :)

    LowStrung said:
    Windows 7 dialogs often ask too many questions. If I want to set the read-only attribute for a folder, I'm asked whether to apply that to the files within it, as well. Most of the time that's not what I want. If I wanted to apply it to the files, I'd go into the folder, select the files and apply the attribute to my selection.
    Setting "Read-only" on a folder doesn't really do anything in W7 (it's basically a way of setting "Read-only" on all files without entering the folder and selecting them).

    "Read-only" only applies to the files in a folder.

    The Properties Windows states this.
    Question about read-only attribute-folder-properties-read-only.png
    If you set that option you'll see a check mark in the checkbox.
    If you close the Properties Window and then reopen it, you'll see that the check mark has been replaced with the blue block (like in the picture above).
      My Computer


  9. Posts : 24
    Windows 7 Starter 32bit
    Thread Starter
       #9

    lehnerus2000 said:
    Currently I have FreeCommander XE set to behave the same as Windows Explorer.
    The behaviour can be changed using options in "Settings > File/folder operations".

    If I change the setting to "Use FreeCommander":

    • Using the "Delete" key or toolbar button generates an additional options window and a warning if I then try to delete a "Read-only" file
    • Using the context menu "Delete" option, it still behaves the same as Windows Explorer

    Question about read-only attribute-fc-xe-file-folder-operations.png
    I wouldn't be surprised if XYplorer has similar options somewhere. :)
    Well, it has an optional feature which I like called "Custom Copy". This is a complete substitute for the corresponding W7 copy, move and replace dialog, as well as the standard progress window. Multiple undo is also present, with a detailed history of file operations during the session so that they can be selectively undone. Beyond that, I believe the only option XYplorer offers relating to Windows Explorer is the treatment of drag & drop operations. By default, drag & drop moves a file if the destination is on the same drive, but only copies it to external drives. XYplorer can be set to change that behavior, although I prefer the default.

    As for deletions, XYplorer uses the standard W7 dialog. In fact, I've noticed at times that on deleting a file, the confirmation box comes up behind XYp's window. I discovered that when there seemed to be no response to the delete key. There was -- I just couldn't see it. This doesn't happen often, and perhaps it's caused by yours truly accidentally switching the focus.

    lehnerus2000 said:
    Setting "Read-only" on a folder doesn't really do anything in W7 (it's basically a way of setting "Read-only" on all files without entering the folder and selecting them).

    "Read-only" only applies to the files in a folder.

    The Properties Windows states this.

    If you set that option you'll see a check mark in the checkbox.
    If you close the Properties Window and then reopen it, you'll see that the check mark has been replaced with the blue block (like in the picture above).
    Understood. The funny thing is, pressing Delete on a folder brings up nothing more than the standard delete confirmation, whether the files inside are read-only or not. I'm not warned that the folder is not empty. I'm always more careful than that, but perhaps Windows needs a "complete idiot" mode for newcomers. Perhaps a "sleepy user" mode, as well.

    Of course, that total destruction can't be done from the command prompt with the RD command, unless the appropriate switches are included.
      My Computer


  10. Posts : 4,049
    W7 Ultimate SP1, LM19.2 MATE, W10 Home 1703, W10 Pro 1703 VM, #All 64 bit
       #10

    LowStrung said:
    Understood. The funny thing is, pressing Delete on a folder brings up nothing more than the standard delete confirmation, whether the files inside are read-only or not. I'm not warned that the folder is not empty. I'm always more careful than that, but perhaps Windows needs a "complete idiot" mode for newcomers. Perhaps a "sleepy user" mode, as well.
    That's why I prefer the way XP handles deletions.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 15:49.
Find Us