Published by


Brink's Avatar
Administrator

Posts: 25,264

Show Printable Version 


How to Set or Unset Read-only Attribute of Files and Folders in Windows 10

information   Information
In Windows, you can set or unset the read-only attribute for files and folders to give files write protection.

Folders cannot actual be set as read-only though. Only files in the folder will be set as read-only instead.

When a file (ex: text file) is set as read-only, the file can no longer be altered since it no longer allows write permission. You will still be able to save your changes to the file as a new file though.

This tutorial will show you different ways on how to set or unset the read-only attribute of files and folders in Windows 10.
Note   Note
Name:  Neutral.png
Views: 1950
Size:  184 Bytes Read-only box = Neutral setting of a folder that is always displayed by default.
Name:  Checked.png
Views: 1954
Size:  267 Bytes Read-only box = File is currently read-only. Only displays temporarily for a folder while setting to be applied to files in folder.
Name:  empty.png
Views: 1949
Size:  165 Bytes Read-only box = File is currently not read-only. Only displays temporarily for a folder while setting to be applied to files in folder.

CONTENTS:
  • Option One: To Set Read-only Attribute of Files and Folders from Properties
  • Option Two: To Unset Read-only Attribute of Files and Folders from Properties
  • Option Three: To Set Read-only Attribute of File using Command Prompt
  • Option Four: To Unset Read-only Attribute of File using Command Prompt
  • Option Five: To Set Read-only Attribute of All Files in Folder and Subfolders using Command Prompt
  • Option Six: To Unset Read-only Attribute of All Files in Folder and Subfolders using Command Prompt
  • Option Seven: To Set Read-only Attribute of File using PowerShell
  • Option Eight: To Unset Read-only Attribute of File using PowerShell
  • Option Nine: To Set Read-only Attribute of All Files in Folder and Subfolders using PowerShell
  • Option Ten: To Unset Read-only Attribute of All Files in Folder and Subfolders using PowerShell


EXAMPLE: File is set to read-only message
Name:  Read-only_message.png
Views: 1971
Size:  10.6 KB






Set or Unset Read-only Attribute of Files and Folders in Windows 10 OPTION ONE Set or Unset Read-only Attribute of Files and Folders in Windows 10
To Set Read-only Attribute of Files and Folders from Properties

1. Open File Explorer (Win+E).

2. Select one or more files and/or folders you want to set as read-only, right click or press and hold on the selected items, and click/tap on Properties. (see screenshot below)

Name:  Read-only_files_Folders_properties.jpg
Views: 2010
Size:  83.0 KB

3. In the General tab, check the Read-only box in the bottom Attributes section, and click/tap on OK. (see screenshots below)

Name:  Set_Read-only_files_Folders_properties.jpg
Views: 1975
Size:  79.9 KB

4. If you selected a folder, select (dot) to either Apply changes to this folder only or Apply changes to this folder, subfolders and files for what you want, and click/tap on OK. (see screenshots below)
Note   Note
Apply changes to this folder only will only not be grayed out if you selected other files or folders in addition with this folder.

If you select (dot) Apply changes to this folder only, any selected folders and their contents will be ignored.
Name:  Confrim_set_read-only_files_Folders.jpg
Views: 1989
Size:  62.3 KB





Set or Unset Read-only Attribute of Files and Folders in Windows 10 OPTION TWO Set or Unset Read-only Attribute of Files and Folders in Windows 10
To Unset Read-only Attribute of Files and Folders from Properties

1. Open File Explorer (Win+E).

2. Select one or more files and/or folders you want to unset as read-only, right click or press and hold on the selected items, and click/tap on Properties. (see screenshot below)

Name:  Read-only_files_Folders_properties.jpg
Views: 2010
Size:  83.0 KB

3. In the General tab, uncheck the Read-only box in the bottom Attributes section, and click/tap on OK. (see screenshots below)

Name:  Unset_Read-only_files_Folders_properties.jpg
Views: 1991
Size:  80.9 KB

4. If you selected a folder, select (dot) to either Apply changes to this folder only or Apply changes to this folder, subfolders and files for what you want, and click/tap on OK. (see screenshots below)
Note   Note
Apply changes to this folder only will only not be grayed out if you selected other files or folders in addition with this folder.

If you select (dot) Apply changes to this folder only, any selected folders and their contents will be ignored.
Name:  Confrim_unset_read-only_files_Folders.jpg
Views: 1972
Size:  61.8 KB





Set or Unset Read-only Attribute of Files and Folders in Windows 10 OPTION THREE Set or Unset Read-only Attribute of Files and Folders in Windows 10
To Set Read-only Attribute of File using Command Prompt

1. Open a command prompt or elevated command prompt based based on the access permissions you have for the file.

2. Type the command below into the command prompt, and press Enter. (see screenshot below)

attrib +r "full path of file with extension"

Note   Note
Substitute full path of file with extension in the command above with the actual full path of the file you want to set as read-only.

For example: attrib +r "C:\Users\Brink\Desktop\Folder\File1.txt"
Name:  Set_Read-only_file_command.png
Views: 1968
Size:  10.3 KB





Set or Unset Read-only Attribute of Files and Folders in Windows 10 OPTION FOUR Set or Unset Read-only Attribute of Files and Folders in Windows 10
To Unset Read-only Attribute of File using Command Prompt

1. Open a command prompt or elevated command prompt based based on the access permissions you have for the file.

2. Type the command below into the command prompt, and press Enter. (see screenshot below)

attrib -r "full path of file with extension"

Note   Note
Substitute full path of file with extension in the command above with the actual full path of the file you want to unset as read-only.

For example: attrib -r "C:\Users\Brink\Desktop\Folder\File1.txt"
Name:  Unset_Read-only_file_command.png
Views: 1968
Size:  10.2 KB





Set or Unset Read-only Attribute of Files and Folders in Windows 10 OPTION FIVE Set or Unset Read-only Attribute of Files and Folders in Windows 10
To Set Read-only Attribute of All Files in Folder and Subfolders using Command Prompt

1. Open a command prompt or elevated command prompt based based on the access permissions you have for the folder.

2. Type the command below into the command prompt, and press Enter. (see screenshot below)

attrib +r "full path of folder\*" /s /d

Note   Note
Substitute full path of folder in the command above with the actual full path of the folder you want to set read-only for all files in this folder and its subfolders.

For example: attrib +r "C:\Users\Brink\Desktop\Folder\*" /s /d
Name:  Set_Read-only_subfolders_and_files_command.png
Views: 1965
Size:  10.3 KB





Set or Unset Read-only Attribute of Files and Folders in Windows 10 OPTION SIX Set or Unset Read-only Attribute of Files and Folders in Windows 10
To Unset Read-only Attribute of All Files in Folder and Subfolders using Command Prompt

1. Open a command prompt or elevated command prompt based based on the access permissions you have for the folder.

2. Type the command below into the command prompt, and press Enter. (see screenshot below)

attrib -r "full path of folder\*" /s /d

Note   Note
Substitute full path of folder in the command above with the actual full path of the folder you want to unset read-only for all files in this folder and its subfolders.

For example: attrib -r "C:\Users\Brink\Desktop\Folder\*" /s /d
Name:  Unset_Read-only_subfolders_and_files_command.png
Views: 1964
Size:  10.3 KB





Set or Unset Read-only Attribute of Files and Folders in Windows 10 OPTION SEVEN Set or Unset Read-only Attribute of Files and Folders in Windows 10
To Set Read-only Attribute of File using PowerShell

Note   Note
To see more usage options for the Set-ItemProperty command, see: Set-ItemProperty - Microsoft Docs

1. Open PowerShell or elevated PowerShell based on the access permissions you have for the file.

2. Type the command below into PowerShell, and press Enter. (see screenshot below)

Set-ItemProperty -Path "full path of file with extension" -Name IsReadOnly -Value $True

Note   Note
Substitute full path of file with extension in the command above with the actual full path of the file you want to set as read-only.

For example: Set-ItemProperty -Path "C:\Users\Brink\Desktop\Folder\File1.txt" -Name IsReadOnly -Value $True
Click image for larger version. 

Name:	Set_read-only_file_PowerShell.png 
Views:	22 
Size:	11.9 KB 
ID:	149304





Set or Unset Read-only Attribute of Files and Folders in Windows 10 OPTION EIGHT Set or Unset Read-only Attribute of Files and Folders in Windows 10
To Unset Read-only Attribute of File using PowerShell

Note   Note
To see more usage options for the Set-ItemProperty command, see: Set-ItemProperty - Microsoft Docs

1. Open PowerShell or elevated PowerShell based on the access permissions you have for the file.

2. Type the command below into PowerShell, and press Enter. (see screenshot below)

Set-ItemProperty -Path "full path of file with extension" -Name IsReadOnly -Value $False

Note   Note
Substitute full path of file with extension in the command above with the actual full path of the file you want to unset as read-only.

For example: Set-ItemProperty -Path "C:\Users\Brink\Desktop\Folder\File1.txt" -Name IsReadOnly -Value $False
Click image for larger version. 

Name:	Unset_read-only_file_PowerShell.png 
Views:	10 
Size:	12.0 KB 
ID:	149305





Set or Unset Read-only Attribute of Files and Folders in Windows 10 OPTION NINE Set or Unset Read-only Attribute of Files and Folders in Windows 10
To Set Read-only Attribute of All Files in Folder and Subfolders using PowerShell

Note   Note
To see more usage options for the Get-ChildItem command, see: Get-ChildItem - Microsoft Docs

1. Open PowerShell or elevated PowerShell based on the access permissions you have for the folder.

2. Type the command below into PowerShell, and press Enter. (see screenshot below)

Get-ChildItem -Path "full path of file with extension" -Recurse -File | % { $_.IsReadOnly=$True }

Note   Note
Substitute full path of file with extension in the command above with the actual full path of the folder you want to set read-only for all files in this folder and its subfolders.

For example: Get-ChildItem -Path "C:\Users\Brink\Desktop\Folder\File1.txt" -Recurse -File | % { $_.IsReadOnly=$True }
Click image for larger version. 

Name:	Set_Read-only_subfolders_and_files_PowerShell.png 
Views:	10 
Size:	11.9 KB 
ID:	149306





Set or Unset Read-only Attribute of Files and Folders in Windows 10 OPTION TEN Set or Unset Read-only Attribute of Files and Folders in Windows 10
To Unset Read-only Attribute of All Files in Folder and Subfolders using PowerShell

Note   Note
To see more usage options for the Get-ChildItem command, see: Get-ChildItem - Microsoft Docs

1. Open PowerShell or elevated PowerShell based on the access permissions you have for the folder.

2. Type the command below into PowerShell, and press Enter. (see screenshot below)

Get-ChildItem -Path "full path of file with extension" -Recurse -File | % { $_.IsReadOnly=$False }

Note   Note
Substitute full path of file with extension in the command above with the actual full path of the folder you want to unset read-only for all files in this folder and its subfolders.

For example: Get-ChildItem -Path "C:\Users\Brink\Desktop\Folder\File1.txt" -Recurse -File | % { $_.IsReadOnly=$False }
Click image for larger version. 

Name:	Unset_Read-only_subfolders_and_files_PowerShell.png 
Views:	13 
Size:	12.1 KB 
ID:	149307


That's it,
Shawn