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

lotster

New member
Local time
2:58 PM
Messages
9
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 Computer My Computer

OS
Windows 7 Home Premium
it works just fine here :D

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 Computer My Computer

Computer Manufacturer/Model Number
Toshiba Satelite P300D 13J (Short model No: PSPDCE)
OS
Windows 7 Enterprise x64 SP1 Version 6.1 Build 7601
CPU
x64bit AMD Turion(tm) X2 Ultra Dual-Core Mobile ZM-82
Memory
4096 (2048 + 2048) MB, DDR2 RAM (800 MHz), max 8,192 MB
Graphics Card(s)
ATI Mobility Radeon™ HD 3650+HyperMemory™(512MB VRAM+2302MB)
Sound Card
Manufacturer: harman/kardon
Monitor(s) Displays
Generic PnP Monitor (MONITOR\LPLA101)
Screen Resolution
1440 x 900 (19" LCD)
Hard Drives
HDD1: TOSHIBA MK3252GSX ATA Device (IDE 320 GB 5,400 o/min) ,
HDD2: Msft Virtual Disk SCSI Disk Device (Virtual Hard Drive),
HDD3: TOSHIBA MK3263GSX USB Device (USB Mobile HDD) (TakeMS MemLine)
PSU
Batery: technology : lithium-ion
Cooling
integrated cooler + 3x external cooler
Keyboard
USB Logitech S520
Mouse
USB Logitech S520
Internet Speed
WAN: 7,2 Mbit/sec, WLAN: 54 Mbit/sec + Bluetooth®
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 Computers My Computers

System One System Two

  • Computer type
    PC/Desktop
    Computer Manufacturer/Model Number
    MSI
    OS
    Windows 11 Prerelease
    CPU
    CORE i5 10400
    Motherboard
    MSI H510M Pro
    Memory
    16GB
    Graphics Card(s)
    GTX 750Ti
    Sound Card
    Realtek HD Integrated
    Monitor(s) Displays
    Samsung Curved 24"; Samsung TV 50"
    Screen Resolution
    1920 x 1080
    Hard Drives
    Vi-Gen NVMe 256GB
    WD 3 TB
    Seagate 2 TB
    Seagate 4TB
    PSU
    Power Striker
    Case
    VBR
    Cooling
    Conventional
    Keyboard
    Logitech Wireless
    Mouse
    Logitech Wireless
    Internet Speed
    2MBPs
  • Computer type
    Laptop
    System Manufacturer/Model Number
    Apple MacBook
    OS
    BigSur
    CPU
    Core i5
    Memory
    8 GB
    Monitor(s) Displays
    13 "
    Screen Resolution
    1366 x 768
    Hard Drives
    SSD 256 GB
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 Computer My Computer

Computer type
Laptop
Computer Manufacturer/Model Number
HP Pavilion TouchSmart
OS
Windows 8, 64 bit OS, x64-based processor, 6Gb RAM
CPU
Don't know
Motherboard
Don't know
Memory
6Gb
Graphics Card(s)
Don't know
Hard Drives
500Mb
Antivirus
Have McAfee & Norton but, usually run with both disabled
Browser
Mozilla Firefox
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 Computer My Computer

OS
Windows 7 Home Premium
Back
Top