Wednesday, July 9, 2008

The Attrib function

The Attrib Function

In the Tutorial on how to kill a pendrive virus, i have found that some of us didn't really understand how the attrib function works. Now in this post, i will describe the use of attrib and shows some sample.

This is what a command prompt will show if we type in : 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.
[drive:][path][filename]
Specifies a file or files for attrib to process.
/S Processes matching files in the current folder
and all subfolders.
/D Processes folders as well.

Some examples:
1. attrib -s
This will remove the System file attribute on every file in that folder.
2. attrib -s /s
This will remove the System file attribute on each file under each folder or subfolder.
3. attrib +h
This will make all files become hidden as it add the hidden file attribute on each file.
4. attrib +h myprograme.exe
This will add the hidden file attribute on the myprograme.exe only.
5. attrib -s -h -r
This will remove all the System file attribute, Hidden file attribute, and also Read-only file attribute on each file.
6. attrib +s +h
This will add system file attribute and hidden file attribute to each file.

0 comments: