0
@echo off  
md folder1   
attrib -s -h -r "folder1" /s /d 
dir c:\windows>>text.txt  
attrib -s -h - r  text.txt  
pause   

Created by simple command md folder1 and in 3rd line I follow advice from
How to remove read-only attribute recursively on Windows 7

This should help to remove attributes [-h],[-s],[-r] with added additional parameters /s & /d to be sure that this will works for folders too.

Everything is working well with file and folders working only with switches [-h],[-s] but so far I can't find a way to remove/change [-r] read-only attribute for any folders or subfolders.

Is there any way to change attributes read-only in folders using batch script or cmd ?
(even if batch is started with admin rights this no change)

What is reason that switch read-only [-r] for empty created folders not working?


Is this Windows Enviroment protection not allow to change folder's [-r] attribute?

  • See if this helps: superuser.com/questions/653951/… – Pimp Juice IT Aug 22 '17 at 0:01
  • Yes, You right- I removed batch & linux tags – Andrzej Orlecki Aug 22 '17 at 6:17
  • Thanks for link I checked if it works in this related topic link .with many answers I tried to open cmd with admin rights and typed :attrib /? - Displays or changes file attributes. for items displays.One of most interesting in my question is switch with ...... "/D it means " Processes folders as well." So I can easily use this 3rd line of my code and add switch" /d " attrib +h - r folder1 /d- It doesn't make any difference attribute read-only remains unchanged. – Andrzej Orlecki Aug 22 '17 at 9:06
  • @GypsyCosmonaut Would u be so kind and tell me how to highlight background of code- I'm beginer and I was trying but couldn't find and have not to much time for that? – Andrzej Orlecki Aug 22 '17 at 19:03
  • Hope this helps superuser.com/editing-help , for code markup, either give 4 spaces at the beginning of the line or enclose your code within `` (backticks) – GypsyCosmonaut Aug 22 '17 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.