How to deny delete/modify permission to a file?

2

I want to deny myself the ability to modify or delete an executable.

When .NET Reflector asks you if you want to update:

enter image description here

and you choose No it spontaneously deletes itself as retribution:

enter image description here

So I want to prevent myself from being able to Delete the executable; as punishment for their punishment.

I tried to Deny me Write permission (and deny it to Everyone, and Administrators):

enter image description here

Except, I can still Right-Click -> Delete the file...

How do I deny the delete/modify permission to a file?

Ian Boyd

Posted 2011-07-12T14:35:24.430

Reputation: 18 244

Upvote solely because I find the question quite amusing. Then I recalled painful times with the Adobe Flash installer and suddenly I feel less amused. – Mark K Cowan – 2014-11-03T11:05:36.370

Yeah, write access has nothing to do with delete permission. This seems like a rather draconian way to solving this problem. – surfasb – 2011-07-12T18:33:40.707

i'm surprised at a downvote. i would think being able to stop something from modifying your files would be a useful question. – Ian Boyd – 2011-08-29T23:12:28.583

@surfasb Write access very well may have nothing to do with delete. i only include things i've tried because some people get grump when i simply ask the question. And some people will give spiteful downvotes if i don't "show research effort". – Ian Boyd – 2012-01-15T15:12:15.627

Answers

3

On Windows, it is enough to have one of:

  • "Delete" on the object, or
  • "Delete child" on its parent

Therefore a file will only become undeletable if you deny both.

Use icacls to edit the permissions:

  • Deny "Delete" to the file:

    icacls Reflector.exe /deny Everyone:(D)
    
  • Deny "Delete child" to the folder:

    icacls . /deny Everyone:(DC)
    

(Tested on Windows XP.)

user1686

Posted 2011-07-12T14:35:24.430

Reputation: 283 655

Denying Modify permission also removes Execute permission; and i can still delete the file! – Ian Boyd – 2011-07-12T18:38:38.663

As I said, "You may also have to deny "Delete items" on the folder"... Which too can be done with icacls. – user1686 – 2011-07-12T20:39:30.170

On the downside that would deny the ability to delete other items in the folder. Given that it doesn't seem to be working, i presume it is not possible to deny the ability to delete a file - deletes must happen against folders, rather than files. – Ian Boyd – 2011-07-13T02:25:01.070

Edit your answer to indicate that it cannot be done, "But here are some alternatives that might be useful", and you'll get the accept. – Ian Boyd – 2011-07-13T02:25:59.900