While Windows Explorer is the best file explorer when it comes to browsing files that we have saved on our hard drives, viruses make use of certain properties in Windows Explorer to disable some important functions. These viruses usually come from USB Flash drives and disable the functions like hidden files can’t be unhidden again etc.
In this situation, the good old DOS can be very helpful as we can use DOS commands to unhide files and folders. This is also beneficial for cleaning the virus from the thumb drive.
To unhide a file from command line, go to Run –> cmd.
This will open DOS command prompt. Now go to the parent folder where the file or folder resides which we want to unhide. To do this, will need to use the cd command (Change Directory). If you want to know about how to use the cd command, run the following command in command prompt:
This will open help for the cd command. When you are in the desired folder, run the following command:
attrib -r -a -s -h *.*
Let’s discuss what this command is doing. Attrib command is used to add or remove attributes to a file. The attributes include read-only, archive, system, hidden etc. To add an attribute, we will need to use a plus (+) sign and to remove an attribute minus (-) sign is used. You can see in the above command that we are removing certain attributes.
So what are the attributes that are being removed? Here’s the explanation:
-r will remove the read-only attribute of the specified file.
-a will remove the archive attribute of the specified file.
-s will remove the system attribute of the specified file.
-h will remove the hidden attribute of the specified file.
*.* means that any file with any extension will be processed with this command. So all the files in the directory where this command is run will be unhidden and will become read-write. You will be able to edit and delete the files.
If you want to unhide all folders + subfolders and files, run the following command:
attrib *.* -h -s /s /d
If you simply want to display a list of hidden files and folders and not change their attributes, run the following command:
I hope this will help people in troubleshooting their systems using the command line.