So what these attributes do? File/folder attributes set the folder accessibility options – for example, specific attributes can determine whether a folder is read-only, hidden or is a system element. Many of these attributes are already set for the vast majority of folders on your PC, however, you can also set those manually, whenever you need to apply those.
In Windows, there are 5 types of file/folder attributes that can be set up. Those are:
- R – Shows whether the file/folder is read-only.
- A – Shows whether the file/folder is archive.
- S – Shows whether the file/folder is a system element that cannot be modified by other users.
- I – Shows whether the file/folder is not content indexed.
- H – Shows whether the file/folder is hidden.
All these attributes can be easily set and removed from any folder on a Windows machine. How can you do this? By using the system console (command prompt).
Either go to Start > All Programs > Accessories > Command Prompt or just launch the Run dialog , type cmd and press Enter.
Now that you launched the system console, you can access the attrib command. This is the command used to set or remove file/folder attributes. Its syntax is the following:
attrib [ [ + | - ] attribute] [path][advanced options]
You already know the attribute types that can be set to a specific file or folder, so I am going to explain the rest of the elements.
The [ + | - ] element shows whether an attribute is being assigned or removed. For example, if I want to set the Hidden attribute to a file, I will use the +H parameter. To remove the attribute, I will use -H. This applies to every single attribute.
The [path] element stands for the file/folder path, that is being subject to manual attribute change. For example, it could be something like C:\MyFolder\MyFile.txt or it could be like MyFile.txt if the file is in the currently active (selected in the console) folder.
The [advanced options] part denotes whether there are advanced options attached to the command. These options could be:
- /S – Processes all matching files in the current folder.
- /D – Will process folders as well.
- /L - Work on the attributes of the Symbolic Link versus the target of the Symbolic Link.
On a side note, a Symbolic Link is a file that is interpreted by the operating system as a path to another file or folder (in fact, it contains the reference to that specific file or folder).
Also, you can set multiple attributes in a single command. For example, the syntax of the following command is absolutely valid:
attrib –H +S +R –A +I MyFile.txt
You might also want to skip some attributes. Therefore, this statement is also valid;
attrib –H +S +I MyFile.txt
When setting attributes, you can write the assigning and removing operators with the attribute type in any order. For example this statement:
attrib –H +S +I MyFile.txt
Will do the same as this one:
attrib +I +S -H MyFile.txt
What is the practical use of manually setting the attributes? From my own experience I can say that setting attributes manually is a way to ensure better protection for your system. You can set specific folders to be hidden or system, while at the same time you can remove these attributes from malicious files.
Have you ever had the problem when you cannot delete a file but you surely know that this one file is malware? This is most likely caused by an automatically set attribute that prevents this. Manually removing the specified attribute comes handy in such situations, as most malicious files are protected from basic deletion and modification.