Difference between revisions of "Windows File Attributes"

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search
 
Line 44: Line 44:
  
 
=== read-only bit ===
 
=== read-only bit ===
 +
 +
The Read-Only attribute will help prevent software programs from saving changes to a file. This is useful if you want to write protect a file. Note that a Read-Only file may not prevent it from being deleted depending on the method used.  Under the old MS-DOS you could set a few files with the Read-only attributes and delete all the files using a "DEL *" (Delete all) command and the read only files would not be deleted.  By design, the read-only bit must be cleared before you can write to a file. 
 +
 
=== hidden bit ===
 
=== hidden bit ===
 +
 +
A file marked with the hidden attribute will be hidden from view under normal viewing conditions.  This is a convenient way to hide the file from standard user-mode software.  However, some software will ignore the Hidden attribute bit so be aware the file with the Hidden attribute bit is not always invisible.
 +
 +
The hidden and system attributes are typically used together for operating system related files. 
 +
 
=== system bit ===
 
=== system bit ===
 +
 +
The system bit denotes a file or directory used exclusively by the operating system which should not be altered or deleted directly by the end user.
  
 
[[Category:Computer Technology]]
 
[[Category:Computer Technology]]

Latest revision as of 06:58, 5 March 2015

The operating systems (MS-DOS, Win95/98, WinNT/2000/XP) maintain a type of meta data known as archive bits associated with every file and directories. In earlier MS-DOS and Microsoft Windows, there were four attributes: archive, hidden, read-only and system. Windows has added a new ones.

A file attribute can exist as only one of two states, set or cleared. Attributes can be in files, directories, volumes and certain system objects. They are used by the operating system and software applications to define file system behavior.

The Primary MS-DOS / Windows File Attributes:

  • archive bit - (shows that the file has not been archived yet)
  • read-only bit - (write-protect the file)
  • directory bit - (distinguishes a directory from a file)
  • hidden bit - (hides from an ordinary directory listing)
  • system bit - (denotes a system file whatever that means)

As new versions of Windows came out, Microsoft has added to the inventory of available attributes on the NTFS file system.

  • compressed - (when set, Windows compresses the hosting file upon storage. For more information, see NTFS § File compression.)
  • encrypted - (when set, Windows encrypts the hosting file upon storage to prevent unauthorized access.)
  • indexed - (when set, Indexing Service or Windows Search do not include the hosting file in their indexing operation.)

Windows 95/98 provide a system utility program, ATTRIB.EXE which is usually stored in the C:\Windows\command\ directory.

ATTRIB command syntax:

   ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] filespec [/S]
      +   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 files in all directories in the specified path.

For example if you want to clear the Archive attribute bit of all the files in a directory, execute the following command line.

ATTRIB  -A c:\mydir\*

archive bit

This bit is used by programs that modify files. One example of software making use of this bit is for file backup. It was common practice for backup software to use the archive bit for keeping track of files that have changed. In this way the software allows incremental backups based on the status of the archive bit. When the backup software archives or backs up the file, it resets the archive bit (cleared). Any software that subsequently makes a change to the file shall set the archive bit (set). Thus when the backup software runs the next time, it will be able to identify the modified files by considering the state of the archive bit. If the bit is set, it will replace the backed up version with the newly modified version. If the bit is still cleared, then the backup software will skip the file assuming that it is the same as what is on the backup archive.

  • Backup software will "clear" the archive bit (remote it from attrib output)
  • Software changing the file will "set" the archive bit (adding the A to attrib output)

Poorly written software may modify the files without setting the archive attribute. If the backup software uses incremental backups to backup these files, it will rely on the software to set the bit appropriately.

read-only bit

The Read-Only attribute will help prevent software programs from saving changes to a file. This is useful if you want to write protect a file. Note that a Read-Only file may not prevent it from being deleted depending on the method used. Under the old MS-DOS you could set a few files with the Read-only attributes and delete all the files using a "DEL *" (Delete all) command and the read only files would not be deleted. By design, the read-only bit must be cleared before you can write to a file.

hidden bit

A file marked with the hidden attribute will be hidden from view under normal viewing conditions. This is a convenient way to hide the file from standard user-mode software. However, some software will ignore the Hidden attribute bit so be aware the file with the Hidden attribute bit is not always invisible.

The hidden and system attributes are typically used together for operating system related files.

system bit

The system bit denotes a file or directory used exclusively by the operating system which should not be altered or deleted directly by the end user.