Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: How do I change system attribute for all folders using command prompt?

25 Feb 2012   #1

Windows 7 Home Premium
How do I change system attribute for all folders using command prompt?

Let me share the background quickly. I work at a school as Computer Applications Technology teacher. The students bring homework to school on their flashdrives, and though we have good antivirus software at school, the viruses on their home PC's will often do considerable damage to the data on their flashdrives.

One of the most common problems we have is some virus that sets the "system" attribute on all folders, effectively hiding them, and then creating shortcuts named after those folders, inviting people to double-click them, thereby effectively installing the virus locally (though our antivirus blocks it). So the problem is that those folders (with their homework) can only be revealed by going into "Folder Options" and selecting "Show hidden files and folders" and removing the option to "Hide protected operating system files". This is a big breach in security. So I usually have to change those settings, run the Attrib command in the command line to change all the folders, and then re-enable the settings. All of this takes up valuable time.

What I would like to know is, is there a way to give the attrib command once, thereby changing the attributes on all folders on a specific flashdrive? I played around with the /S /D and *.* settings, but couldn't accomplish anything. Any advice would be greatly appreciated!

Thank you!

My System SpecsSystem Spec

25 Feb 2012   #2

Windows 7 Enterprise x64 SP1 Version 6.1 Build 7601

it works just fine here

assuming we are in root of the flash drive which holds some files and subfolder with some files with....
attrib +r +s +h /S /D will add these attributes:
-read only
-system file
-is hidden
-Processes matching files and all subfolders.
-Processes folders as well

now if you wanna remove attrubutes for all files in all folders on whole flashdrive do this:
attrib -r -s -h /S /D
this command will remove attrubutes for all files folders and subfolders:
-read only
-system file
-is hidden
-Processes matching files and all subfolders.
-Processes folders as well

it works as expected

you was probably typing something wrong
My System SpecsSystem Spec
25 Feb 2012   #3

Windows 7 Ultimate x64

Hi Lotster.
In normal condition, on non infected files and folders those command line syntax given by Code kiddy should perfectly work.

Btw, I'm familiar with your situation, as it always happens here.
As you mentioned, always have setting which reveal hidden files and folder is actually good for us.
Some viruses create permanent hidden attributes to those files on the drive root and to folders on the flashdrive (but sometimes not to the files inside the folders). Any command line or changing files/folders properties won't do any good. So then the last option is creating new folder and move all files to it. and for hidden files the only way is to open it and save it as under different name. That is totally painful, but that what I always do in helping friends.

As preventive measures aside from your antivirus, you may help the students by trying this following tips.
  1. Never put files into flashdrive root. Always put into folder (unless it's a flashdrive with special purpose, boot drive, or else). once the folder infected we can stil have the files a bit safer.
  2. When finished scanning flashdrive with any AV program but still suspect it, navigate the flashdrive with explorer in a way that always do a click on the left pane of explorer (which only single click needed instead of harmful double click on right pane, it's what those viruses want).
  3. Delete any visible shortcuts, any folder named recycler, any unknown exe files, any unknown dll files, any files with no extension but having system icon on it, any unknown autorun.inf (some won't, as it belongs to some AV program). Most of them appear as hidden (or sometimes read only) things.
Note: It won't work with infected system

Sorry it's little bit long but worth reading, I hope.

My System SpecsSystem Spec


 How do I change system attribute for all folders using command prompt?

Thread Tools

Similar help and support threads for2: How do I change system attribute for all folders using command prompt?
Thread Forum
Change Command Prompt Default Directory Customization
How would I run system restore from command prompt? Can not boot... Backup and Restore
System Level Command Prompt General Discussion
Solved Cannot change drive in command prompt using CD General Discussion
Solved Change Directory in Command Prompt General Discussion
Change time to display OS from installation disk command prompt Installation & Setup
Command Prompt to change primary monitor? General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 07:31 AM.
Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33