2

You can create a "locked" RAR archive using WinRar such that the files can't be modified or deleted, and they become readonly without using a password. Is it also possible with 7z format?

It is interesting that applying "readonly" attributes to a 7z archive doesn't protect it from being modifed!

8
  • 1
    What would this achieve? If I can read the contents, I can very easily extract all the files, modify some, and re-package them. If you want to stop a file (such as a *.7z archive) from being modified, you need to remove read permissions on the filesystem level (This is not the same as the readonly attribute on Windows systems). Oct 24, 2013 at 19:58
  • 1
    @DarthAndroid: Would good would the file be with its read permissions removed?
    – martineau
    Oct 24, 2013 at 20:10
  • @DarthAndroid By applying the password via WinRar you can make archive read only but you cannot read the content of files, meaning that you can see just the list of the files inside archive. If you include the encryption, than you will not be able to see neither the content of archive. Oct 24, 2013 at 20:39
  • @martineau Well, the idea would be that the read permissions would be removed for some users, and granted to other users, in the same way that some users would not know an encrypted archive's password, and some users would. Oct 24, 2013 at 22:11
  • 1
    I'm not looking for encryption. Locked archives enables me to classify files in organized packages. For example all of the files needed to run a portable app can be backed up into such an archive, if a file is deleted the app may not run after extracting
    – QED
    Oct 25, 2013 at 17:39

1 Answer 1

1

I can't seem to find anything in the 7zip documentation about locking it's files. For the moment I'll assume it is specific to the RAR compression algorithm.

As for actually locking the file, there are some options:

  • As you stated, setting the file attribute doesn't stop 7zip from altering it's contents. Quoting from Wikipedia:

    Read-only: When set, indicates that a file should not be altered. Upon opening the file, file system API usually does not grant write permission to the requesting application, unless the application explicitly requests it. Read-only attributes on folders are usually ignored.

  • You can use the attrib command to alter the read attribute, but this might fall on the previous point.

  • You can use the cacls command, that works on filesystem level and should be impervious to Windows behavior. A sample usage is the following:

    CACLS C:\file.7z /E /G "User_Name":R
    

    This will give Read-only access to the .7z file, at NTFS level. This will not work if the drive is FAT32 or other format. I assume an easier way to do this would be from the Security Tab in the file's properties, and give only read control to the users.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .