Changing file attributes in MS-DOS

Notice that the title is "Changing file attributes in MS-DOS". This means, this document only applies to MS-DOS file attributes. Windows NT holds both MS-DOS and NTFS file attributes on NTFS volumes. Both Windows NT and Windows 9x hold only MS-DOS file attributes on non-NTFS volumes. Here I only talk about MS-DOS file attributes.

I think you must have wondered why the following files on a MS-DOS start-up disk are invisible: IO.SYS, MSDOS.SYS. Let me tell you the reason: they have been set to bear a HIDDEN attribute and a SYSTEM attribute. Any of those two can cause the file invisible. Also, you may wonder why these files on a MS-DOS (versions from 5.0) start-up disk cannot be directly deleted using DEL or ERASE command: IO.SYS, MSDOS.SYS and COMMAND.COM. This is also because of MS-DOS file attributes: They have been set to bear a READ-ONLY attribute.

I think you've read about directory entries in my document "FAT and the Directory Structure". You may have some knowledge about MS-DOS file attributes stored in directory entries. MS-DOS file attributes are represented by bits. You can see the layout of MS-DOS file attributes in directory entries in that document, and they are all available MS-DOS file attributes. All available MS-DOS file attributes are listed here: read-only, hidden, system, label, subdirectory and archive.

You can set a file's attributes using the ATTRIB command. Run ATTRIB.EXE to change or view file attributes at MS-DOS command prompt. Also, you can change file attributes using Windows Explorer. To do this, right click on the file and select "Properties", then switch to the "Regular" tab. You can change the attributes there.

Below are the usage of ATTRIB.EXE:

Microsoft Windows 2000 [Version 5.00.2195]
 
(C) Copyright 1985-2000 Microsoft Corp.
 
C:\Documents and Settings\Decheng\Desktop>attrib /?
 
Displays or changes file attributes.
 
ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [[drive:] [path] filename]
       [/S [/D]]
 
  +   Sets an attribute.
 
  -   Clears an attribute.
 
  R   Read-only file attribute.
 
  A   Archive file attribute.
 
  S   System file attribute.
 
  H   Hidden file attribute.
 
  /S  Processes matching files in the current folder
 
      and all subfolders.
 
  /D  Processes folders as well.
 
 
C:\Documents and Settings\Decheng\Desktop>
 
 
 

Do not take for granted that you can make an MS-DOS start-up disk by simply copying IO.SYS, MSDOS.SYS and COMMAND.COM to a floppy disk and then changing the attributes of them. Actually whether to set the attributes of the files or not doesn't affect whether the disk could start-up. You can do an experiment: Release all attributes of the files IO.SYS, MSDOS.SYS and COMMAND.COM on a start-up disk and then restart the computer with it. It would be all right. The key to this problem is: Firstly the boot record must contain the boot program for MS-DOS (floppy disks usually do). Secondly, the first 512 bytes of IO.SYS must locate at the beginning of the first cluster on the disk. That's all it need to be.

Return to MS-DOS for Beginners