Set read-only attribute from command line

We can mark a file as read-only from the command line too. Command for this is given below.

attrib +R  filename

Example:

Advertisement
attrib +R example.doc

The above command will set the read only attribute for the file file.doc and user will not be able to do modifications to the file.

To check if a file has read only attribute set, you can check by running attrib command on the file.

 attrib filename

Example:

D:data> attrib example.doc
A    R       D:dataexample.doc

Recursively set read-only attribute for all files in the directory

attrib /S +R

2 thoughts on “Set read-only attribute from command line”

  1. Forgot to mention. This is a good alternative to dowloading those free utilities to get read only files onto the Pocket PC.

    Reply

Leave a Comment