Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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!

share|improve this question
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). –  Darth Android Oct 24 '13 at 19:58
    
@DarthAndroid: Would good would the file be with its read permissions removed? –  martineau Oct 24 '13 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. –  Nikola Dimitrijevic Oct 24 '13 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. –  Darth Android Oct 24 '13 at 22:11
    
@NikolaD What purpose is seeing the filenames if you can't see the file contents? –  Darth Android Oct 24 '13 at 22:13
show 3 more comments

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.