Block file or folder from deletion

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
btk
Posts: 13
Joined: 17 Apr 2014 21:51

Block file or folder from deletion

#1 Post by btk » 30 Sep 2014 21:49

I am researching but I am not able to find a solution to lock file or folder on the command line against exclusion.

Suggestions?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Block file or folder from deletion

#2 Post by foxidrive » 01 Oct 2014 00:25

Use attrib and hide it, delete and then remove the hidden attribute again.

It does depend on the method of deletion you are using - say Robocopy with the /mir switch won't respect this.

btk
Posts: 13
Joined: 17 Apr 2014 21:51

Re: Block file or folder from deletion

#3 Post by btk » 01 Oct 2014 06:25

It is possible by command line, change file permissions?
For this is the way I wanted to do.

ShadowThief
Expert
Posts: 1162
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: Block file or folder from deletion

#4 Post by ShadowThief » 01 Oct 2014 06:35

Yes, you can use the icacls command. http://ss64.com/nt/icacls.html

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Block file or folder from deletion

#5 Post by foxidrive » 01 Oct 2014 07:10

btk wrote:It is possible by command line, change file permissions?
For this is the way I wanted to do.


Sometimes people ask a question and say what they want to do.

This was not one of those days. :D

btk
Posts: 13
Joined: 17 Apr 2014 21:51

Re: Block file or folder from deletion

#6 Post by btk » 01 Oct 2014 07:20

ShadowThief wrote:Yes, you can use the icacls command. http://ss64.com/nt/icacls.html



Perfect !!!!
:D

Samir
Posts: 384
Joined: 16 Jul 2013 12:00
Location: HSV
Contact:

Re: Block file or folder from deletion

#7 Post by Samir » 30 Oct 2014 06:05

The only caveat to this command is that it does not work on FAT-based file systems (FAT, FAT32, etc) since they do not store any ACL info.

Post Reply