General Set or Unset Read-only Attribute for Files and Folders in Windows 11

  • Thread starter Thread starter Brink
  • Start date Published: Start date Updated Updated:

Read-only_banner.webp

This tutorial will show you different ways to set or unset the read-only attribute for files and folders in Windows 10 and Windows 11.

You can set or unset the read-only attribute for files and folders to give files write protection.

When setting a folder as read-only, read-only is actually only applied to all files in the folder and subfolders instead. A folder itself will not be read-only.

When a file is set to be read-only, write permissions are removed. This prevents the file from being edited or modified. For example, any edits to a read-only text file will have to be saved as a new file.

You will still be able to delete a read-only file.

Reference:



Contents

  • Option One: Set or Unset File as Read-only from File Properties
  • Option Two: Set or Unset All Files in Folder and Subfolders as Read-only from Folder Properties
  • Option Three: Set or Unset File as Read-only using attrib Command
  • Option Four: Set or Unset All Files in Folder and Subfolders as Read-only using attrib Command
  • Option Five: Set or Unset File as Read-only in PowerShell
  • Option Six: Set or Unset All Files in Folder and Subfolders as Read-only in PowerShell


EXAMPLE: File set to read-only message

Read-only_message.webp





Option One

Set or Unset File as Read-only from File Properties


1 Right click on a file you want, and click/tap on Properties.

2 In the General tab, check (set) or uncheck (unset - default) the Read-only attribute for what you want. (see screenshots below)

3 Click/tap on OK.

Read-only_attributes_file_properties-1.webp
Read-only_attributes_file_properties-2.webp





Option Two

Set or Unset All Files in Folder and Subfolders as Read-only from Folder Properties


1 Right click on a folder you want, and click/tap on Properties.

2 In the General tab, check (set) or uncheck (unset - default) the Read-only attribute for what you want, and click/tap on OK. (see screenshots below)

Read-only_attributes_folder_properties-3.webp
Read-only_attributes_folder_properties-1.webp
Read-only_attributes_folder_properties-2.webp

3 Click/tap on OK to Apply changes to this folder, subfolders and files. (see screenshots below)

Read-only_attributes_folder_properties-4.webp
Read-only_attributes_folder_properties-5.webp




Option Three

Set or Unset File as Read-only using attrib Command


1 Open Terminal or Terminal (Admin) based on the access permissions you have for the file, and select either Windows PowerShell or Command Prompt.

2 Type the command below you want to use into Terminal, and press Enter. (see screenshots below)

Set read-only
attrib +r "<full path of file with extension>"

OR​

Unset read-only
attrib -r "<full path of file with extension>"

Substitute <full path of file with extension> in the commands above with the actual full path of the file you want to set or unset as read-only.

For example: attrib +r "C:\Users\Brink\OneDrive\Desktop\File.txt"


Read-only_attributes_file_command-1.webp

Read-only_attributes_file_command-2.webp





Option Four

Set or Unset All Files in Folder and Subfolders as Read-only using attrib Command


1 Open Terminal or Terminal (Admin) based on the access permissions you have for the folder, and select either Windows PowerShell or Command Prompt.

2 Type the command below you want to use into Terminal, and press Enter. (see screenshots below)

Set read-only
attrib +r "<full path of folder>\* /s /d"

OR​

Unset read-only
attrib -r "<full path of folder>\* /s /d"

Substitute <full path of folder> in the commands above with the actual full path of the folder you want to set or unset all files in the folder and subfolders as read-only.

For example: attrib +r "C:\Users\Brink\OneDrive\Desktop\Folder\* /s /d"


Read-only_attributes_folder_command-1.webp

Read-only_attributes_folder_command-2.webp





Option Five

Set or Unset File as Read-only in PowerShell


1 Open Terminal or Terminal (Admin) based on the access permissions you have for the file, and select Windows PowerShell.

2 Type the command below you want to use into Terminal, and press Enter. (see screenshots below)

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

OR​

Unset read-only
Set-ItemProperty -Path "<full path of file with extension> -Name IsReadOnly -Value $False"

Substitute <full path of file with extension> in the commands above with the actual full path of the file you want to set or unset as read-only.

For example: Set-ItemProperty -Path "C:\Users\Brink\OneDrive\Desktop\File.txt" -Name IsReadOnly -Value $True


Read-only_attributes_file_PowerShell-1.webp

Read-only_attributes_file_PowerShell-2.webp





Option Six

Set or Unset All Files in Folder and Subfolders as Read-only in PowerShell


1 Open Terminal or Terminal (Admin) based on the access permissions you have for the folder, and select Windows PowerShell.

2 Type the command below you want to use into Terminal, and press Enter. (see screenshots below)

Set read-only
Get-ChildItem -Path "<full path of folder>" -Recurse -File | % { $_.IsReadOnly=$True }

OR​

Unset read-only
Get-ChildItem -Path "<full path of folder>" -Recurse -File | % { $_.IsReadOnly=$False }

Substitute <full path of folder> in the commands above with the actual full path of the folder you want to set or unset all files in the folder and subfolders as read-only.

For example: Get-ChildItem -Path "C:\Users\Brink\OneDrive\Desktop\Folder" -Recurse -File | % { $_.IsReadOnly=$True }


Read-only_attributes_folder_PowerShell-1.webp

Read-only_attributes_folder_PowerShell-2.webp



That's it,
Shawn Brink


 
Last edited:

Latest Support Threads

Back
Top Bottom