How To Use The CMD Prompt To Change A File or Directory Attributes
Change a file or directory attributes (folder) to recover from a virus attack...
Sometimes a corrupt file system will change access to files, sometimes it is a virus, and sometimes it is a user with the wrong set of rights. Either way a hidden or read only will keep you from using a file.
Seems there is a nasty virus out on the web that likes to hide directories (Folders) and files from the user/owner. This is called Change A File or Directory Attributes.
Change A File or Directory Attributes:
You tried to remove the hidden attribute on some files and folders with Explorer but it isn't working.
You need to have two things:
First you need to check the security of the drive volume in question, with the properties window open on the drive you need to find out who owns the files on the volume, go to the Security tab.
On the Owner tab you should see Administrators and your user ID if you do not see your user ID then you DO NOT have Administrative rights on the computer! You need to either log on with the Administrator's ID or add your user ID to the Administrators Group.
If you are not sure that you "Own" the files then close the drive properties and open Explorer, go to the Folder in question and check the properties, Go to the Owner tab and look at the "Owner" if your user ID is there, highlight your user ID the check the box "Replace owner on sub containers and objects" this will give you ownership of the Folder and all sub folders and files under that folder.
From there you should be able to use Explorer to change the hidden attribute from the folder, sub folders, and files.
If not read on ~
Change a file or directory attributes using the CMD prompt:
One of the ways to gain control over a file or directory (this is an old DOS term where as Folders is a Windows 95 and up term) is to use the Command Prompt and go to the directory with the effected files.
Ah but, you say "How do I get there?"
Now you have a list of all the commands you can use in the Command Prompt window or with a DOS boot disk, however with a DOS boot disk unless you have a utility that will mount an NTFS volume you will not be able to do anything to a Windows volume, DOS can not see the NTFS formatted volume.
Either use the Start button menu and navigate to the accessories and open a Command Prompt window or use the Run... from the Start button menu and type in cmd, a new window will open at the Command Prompt.
Change a file or directory attributes...
Next you need to navigate to the actual directory, lets say the path to the affected files is D:\Backup Files\June 2010 now you have a small problem because some DOS commands do not see spaces in a directory name, and when you get to the files you are going to have another problem: DOS can only see eight characters and a three character file type extension.
There are ways around these small problems. When you are using some commands/utility programs in the CMD Prompt you can not use spaces and long file names with some commands such as attrib unless you enter your text with in parentheses such as you want to go to the backup files directory you would use this: "backup files" with the command.
Before you go to the backup files directory if it is hidden you need to remove that attribute by using the attrib -h command (don't worry I will make a complete list of how to get to the drive letter, the directory, and the files shortly).
When the CMD Prompt window opens it will be on your Operating System drive and in your home or My Documents directory unless you have changed it by changing the properties of the CMD Prompt itself (I have mine set for C:\ ) so you need to get to the D: drive then to the backup files root directory for the June 2010. That is where you need to start removing the -h (hidden) attribute from the files and directories.
Change a file or directory attributes CMD prompt instructions:
Next you go to your CMD Prompt and use the DOS syntax (type in the command - commands are all bold - explanations are not) as follows:
Once you have removed the hidden attribute from the files and folder then using Explorer check your work by doing a properties on the folder then some of the files in the folder.
Change a file or directory attributes:
But you say "There are folders inside the D:\Backup Files\June 2010\ folder!"
Then you would have to run the attrib command on each directory then inside each directory, yes it is a lot of work but if Explorer can't do the job and you don't have the old NT File Manager then you will have to do it the hard way, one folder at a time.
A list of commands that I used to change a file or directory attributes in this example:
What if you copied some files from a CD or DVD? Did you know that the files on a CD or DVD have the Read Only attribute? When you copy the files the attribute follows and all files copied will be read only. Normally that will be ok but if you need to change a file or directory attributes or if a file is a template that you want to use you will not be able to save your work until you remove the read only attribute or use a different name for the file.
You can use Explorer to remove the read only but if Explorer can't remove the attribute then use the steps above and replace the letter h with the letter r.