How to deny delete/modify permission to a file?
10,921
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.)
Related videos on Youtube
Author by
Ian Boyd
Updated on September 18, 2022Comments
-
Ian Boyd over 1 year
I want to deny myself the ability to modify or delete an executable.
When .NET Reflector asks you if you want to update:
and you choose No it spontaneously deletes itself as retribution:
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):Except, I can still Right-Click -> Delete the file...
How do I deny the delete/modify permission to a file?
-
surfasb almost 13 yearsYeah, write access has nothing to do with delete permission. This seems like a rather draconian way to solving this problem.
-
Ian Boyd over 12 years@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".
-
Mark K Cowan over 9 yearsUpvote solely because I find the question quite amusing. Then I recalled painful times with the Adobe Flash installer and suddenly I feel less amused.
-
-
Ian Boyd almost 13 yearsDenying
Modify
permission also removesExecute
permission; and i can still delete the file! -
user1686 almost 13 yearsAs I said, "You may also have to deny "Delete items" on the folder"... Which too can be done with icacls.
-
Ian Boyd almost 13 yearsOn 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 almost 13 yearsEdit your answer to indicate that it cannot be done, "But here are some alternatives that might be useful", and you'll get the accept.