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.
More,
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.

Kevin
My System SpecsSystem Spec
.


1 Week Ago   #4

Windows 8, 64 bit OS, x64-based processor, 6Gb RAM
 
 

Notwithstanding it has been 922 days (as of this post) that there has been any activity on this question, it might be helpful for others who are having this problem to learn of my experiences in fixing it.

I'm also posting here as I specifically got an account on this site just so I could thank CodeKiddy for his solution but, found no way of doing it other than by posting here.

The problem started when I was transferring files from one computer to the next (both of which were Windows 7 OS and the USB flash drive being used has been also used on my new, you beaut, Windows 8 Laptop) and when I inserted the USB flash drive all my files momentarily showed then all disappeared. I thought I had picked up a virus.

Searching the net I found an explanation that went like this: the PC the USB went into saw certain file extensions that lead it to believe it was a camera that had been connected (there was one .jpg file on the USB drive) and so it automatically hid my other files (.dwg, word, excel, .pdf, etc). As the .jpg didn't show I discounted this and, to be frank, I was less interested in the 'why' more so than I was interested in the 'how' to fix it...

The first solution I found was:
“cmd”
“d:” (or whatever USB port your flash drive is in)
“dir / ah”
[for files] “attrib (each file name & its extn e.g. fred.jpg) -r –a –s –h”
Or
[for folders] “attrib (each folder name BUT, if the folder had more than 6 characters, type the first 6 characters then ~1 e.g. COMPLI~1) –r –a –s –h”
This worked for some files and folders and not for others (probably typos on my part) but, is a seriously sssslllloooowwww method, especially if there are heaps of files/folders to change.
I knew that there had to be a global way of doing this and ÇodeKiddy, via this question by lotster, proved that there was.
Again, ÇodeKiddy thank you for freely giving your time to share your knowledge to help us computer illiterates out.
My System SpecsSystem Spec
1 Week Ago   #5

Windows 7 Home Premium
 
 

Wow, I had forgotten all about this post already, and now I see that I forgot my manners completely by never thanking Codekiddy and Kevin. But yes, I agree with Cupsay, the answers helped me a lot, I've used the attrib command about a zillion times since then, and always looked awesome doing it (there's nothing like watching a school kid's face light up when he / she sees their hard work re-appear after the teacher did some "awesome hacking"! ) So, thank you guys!!
My System SpecsSystem Spec
Reply

 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 04:50 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