How to Set Windows to Read All Files

When y'all need to ensure a file isn't changed under any circumstances in Windows, it'due south time to get in read-only. Setting a file every bit read-only or write-protecting a file prevents any changes any. If y'all don't know how to set files equally read-merely and demand to, yous're in the correct place!

In this tutorial, you're going to learn how to fix and remove the read-but aspect in File Explorer, the control-line (cmd), and via PowerShell!

Let'south become going.

Prerequisites

This mail will be a hands-on tutorial. If you'd like to follow forth, be sure you have the following:

  • A Windows PC. This tutorial will use Windows 10 and Windows PowerShell v5.1.
  • A file to toggle the read-but aspect on. This tutorial volition use a file located at C:\Shared\readme.txt.

How to Make a File Read-Just (and Writable) in File Explorer

In that location are a few dissimilar ways to set a file equally read-simply merely let's start out this tutorial by get-go covering how to make information technology happen via Windows File Explorer.

The read-only aspect is stored every bit a metadata property rather than in the content of the file. The property can be seen through Windows File Explorer.

Assuming that you're on the desktop of your Windows PC:

1. Open Windows File Explorer and navigate to the folder that stores the file y'all'll be working with (C:\Shared) in this case.

2. Right click the file and click Backdrop to open the file'south Properties box. This box contains diverse metadata nearly that item file such equally size, when it was created, modified, etc. It also has file attributes.

Click the read-but checkbox in the Attributes group to write-protect the file or prepare it as read-only, click Apply to assign the read-only attribute, and OK to close the dialog box.

The properties box of the file readme.txt. Note the location of the Read-only attribute check box and the Apply button.
The properties box of the file readme.txt. Notation the location of the Read-simply attribute check box and the Employ button.

Similarly, to remove the read-only attribute from the file, uncheck the Read-only checkbox.

How to Make a File Read-Only (and Writable) via Control Line

File attributes aren't just exposed via File Explorer. You can also dispense file attributes including the read-merely aspect via the command line. To do so, yous must employ a command called attrib.

1. Open a command prompt (cmd.exe).

two. Navigate to the folder the file is in.

3. Run attrib with no parameters. The attrib control will immediately look for all files in the working directory and render all files and the enabled file attributes. Y'all tin meet below the readme.txt file does non accept the read-only attribute enabled.

Archive attribute enabled (A) but no read-only attribute (R)
Annal attribute enabled (A) but no read-only attribute (R)

four. Now, run attrib to assign the read-merely aspect. The +r parameter is central here. This parameter tells Windows to gear up the read-only attribute on the file.

5. Run attrib again with no parameters to verify the read-only aspect was applied. You lot tin can now see in the screenshot below the R label shows up indicating the read-but attribute has been applied write-protecting the file.

Read-only attribute (R) is now enabled
Read-only attribute (R) is now enabled

Similarly, to remove the read-merely attribute use the -r parameter.

How to Brand a File Read-Only (and Writable) with PowerShell

If you're not a fan of the GUI or the command prompt or want to use have a little more ease of control, look no further than PowerShell! Let'south at present learn how to brand a file read-only with PowerShell!

  1. Open Windows PowerShell.

ii. Run the Get-Item cmdlet providing the path to the file you're toggling the read-only attribute on. The Attributes holding returned contains each file attribute that's currently enabled.

            get-item -Path "c:\shared\readme.txt" | format-table proper noun, attributes          
The Archive attribute is only enabled.
The Archive aspect is simply enabled.

Using the Format-Tabular array cmdlet is not necessary but by doing so, tells PowerShell to display only the ii properties y'all're interested in in an piece of cake-to-view format (Proper name and Attributes)

iii. Assign the read-only aspect by adding the ReadOnly attribute to the Attributes property equally shown below.

            ## Capture the file object in the $file variable  $file = Get-Item -Path "c:\shared\readme.txt" ## Non to overwrite the existing attributes, create a new array containing ## the current file attributes while calculation the ReadOnly attribute and assign ## that array as the new value of the Attributes property  $file.Attributes = @($file.Attributes,"ReadOnly")          
Assigning the Read Only Attribute
Assigning the Read Only Attribute

4. At present, view the Attributes property of the $file object and you lot'll run across that you've now applied the ReadOnly aspect to the file while maintaining any existing attributes that existed on the file beforehand. You can as well run Become-Item once more to view the same results.

Viewing the Attribute Property
Viewing the Attribute Holding

To remove the ReadOnly aspect from the file, follow the verbal same approach but this time fix the value of the Attributes property to Normal e.g. $file.Attributes = "Normal".

Conclusion

Y'all should now know how to set up a file as read-just and vice versa. Setting a file every bit read-simply is meant to foreclose accidental changes. But know that, setting a file as read-merely is not necessarily a security measure and does non prevent access to the file or someone from just irresolute the attribute themselves.

Armed with this new knowledge of protecting files from existence accidentally overwritten, do you have any files you'd like to protect?

buckaune1936.blogspot.com

Source: https://adamtheautomator.com/how-to-make-a-file-read-only/

0 Response to "How to Set Windows to Read All Files"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel