Hi Soheb Khan,

You can create a group policy to deny the delete permission on the folder. Open Group Policy Management Editor, navigate to Computer Configuration / Policies / Windows Settings / Security Settings / File System and set the user permissions in the advanced permissions.

Best Regards,

Ian Xue


If the Answer is helpful, please click "Accept Answer" and upvote it.

Discussions

Is there a software or tool to restrict users from deleting files and folder?
Hi there I have been going through forum regarding restricting people from deleting the files. But dont think i have found any solution yet. I have a windows server, and would like to restrict people from deleting the files. Using NTFS permissions i know we cannot as they cannot modify either. More on community.spiceworks.com
🌐 community.spiceworks.com
22
24
May 9, 2022
How to restrict users from deleting files and folders in Windows Server 2019
I have a domain server and a file-share server. I would like to let domain users modify files but prevent them from deleting them. When I try to do this, it works for Notepad ".text files", but I get an "Access Denied" error when… More on learn.microsoft.com
🌐 learn.microsoft.com
1
0
February 14, 2024
Protect files from being deleted
How do I protect files and/or folders from being deleted? Our Photos and Videos are our most valuable possession and they need better protection - from us. We back up to external drives. But, we would also like to “lock” the files to ensure that when… More on answers.microsoft.com
🌐 answers.microsoft.com
32
460
January 3, 2010
How do you restrict staff’s ability to create/delete/modify folders only in a shared drive but not the files?
How do you restrict staff’s ability to create/delete/modify folders only in a shared drive? However staff should continue to be able to Create/save/delete/modify files within these folders and anywhere on the shared drive? More on learn.microsoft.com
🌐 learn.microsoft.com
1
0
🌐
QNAP
qnap.com › en-in › how-to › faq › article › how-can-i-restrict-users-from-deleting-files-and-folders
How can I restrict users from deleting files and folders? | QNAP (IN)
January 4, 2023 - Click Add. The Edit Principal window opens. Configure account permissions. Under Type, select Deny. Select Delete subfolders and files. Select Delete (files only). ... The system restricts the user from deleting any data within the specific folder.
Top answer
1 of 2
1

In Windows a file generally gets its ACL from the folder in which it is created. If the folder allows non-owners of files to delete them, then they can even if the owner is an administrator.

As you note you can change this for a file, a folder or a folder tree.

To change for all folders you need to first identify which folder trees you want to change (e.g. you shouldn't start changing permissions of C:\Users, C:\Windows, ... and other system folders).

Then for each of these you need to modify the ACL. This can be done in code or script (e.g. PowerShell), but needs more time to write up than I have now (if you just want to copy one ACL to another folder you can get-acl on the first and then set-acl on the other).

However I would suggest you consider why you want to do this. If a user needs to create files that only they can delete the best route is to create a folder, with specific ACL, for that purpose. Not to make some global change so the administrator doesn't have to think.

2 of 2
1

When you make a folder as admin it and its contents apply a default security level that gives accounts in the Users group read and execute but not delete. I would agree with Richards comment rather than defining explicit permissions I would define what you want to do and make sure that the other user accounts use the proper user group. If you have other user accounts and they are in the administrator group they will be able to access any folders if they drill down to the file system as admin. Even if you set explicit permissions to one user account a user in the admin group can take ownership and then make any changes they want. Only a more limited account will prevent that.

🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1532373 › how-to-restrict-users-from-deleting-files-and-fold
How to restrict users from deleting files and folders in Windows Server 2019 - Microsoft Q&A
February 14, 2024 - A "file delete" is part of the ...les-fe847711-96cf-5978-00ae-46e30db88982 · Have the user copy the file to their C:\ drive, update that file, and then copy it back to the server....
🌐
iSumsoft
isumsoft.com › windows-tips › how-to-protect-files-from-being-deleted.html
How to Protect Files from Being Deleted in Windows 10
January 11, 2024 - Enter the File Explorer window and select the View tab. Then in the Options tab, select Change folder and search options. In the Folder Options dialog, click on the View tab. Make sure the option Don’t show hidden files, folders, or drives is selected. Click on the button Apply and OK.
Find elsewhere
Top answer
1 of 2
6

I am trying to prevent users from accidentally deleting a certain folder in a parent folder, while still giving them modify permission on all other files and folders in the parent folder. But they should be also able to modify files and folders in this certain folder

Prevent Folder Deletion or inadvertent Drag and Drop with NTFS security

If you want to prevent a specific folder from being deleted or dragged and dropped elsewhere, even if it has elevated implicit permissions, you can set an explicit DENY to the FOLDER ONLY for the user account or security group which you want to prevent this action from being performed.

You can complete this folder security lock down using ICACLS with a local path (e.g C:\Path\FolderA\FolderE) or a UNC path (e.g \\server\share\FolderA\FolderE).


Example ICACLS syntax to run from an elevated command prompt

ICACLS "\\server\share\FolderA\FolderE" /deny "<UserOrGroupNameToDeny>":(DE)

Permissions Used

/deny user:permission
   Explicitly deny the specified user access rights.
   This will also remove any explicit grant of the 
   same permissions to the same user.

perm is a permission mask and can be specified in one of two forms:
   a comma-separated list in parentheses of specific rights:
         DE - delete

What this does

Running the above with those options in that syntax will set an explicit DENY to the NTFS DELETE permission on that FOLDER ONLY to that specific user account of security group.

You can confirm the deny permissions to the folder for the user account or security group by:

  • right-click the folder you've used in the command,
  • Select the Security tab,
  • In the Group or user name: area scroll to or select and highlight the account or group you've used in the command,
  • In the Permissions for Administrators area you will see the NTFS permission attributes for Allow and Deny
  • You'll see a check mark in the DENY column of the special permissions row for the account or group you've used in the command

  • Select Advanced and go to the Permissions tab
  • Check for the Name (or Principal) value that you used in command, for DENY in the Type field
  • The Permissions (or Access) field should show Delete and the Apply to (or Applies to) will show this folder only


NOTES

Please note that unchecking an ALLOW DELETE attribute is not the same as leaving that in place as-is and then creating a separate NTFS ACL rule for this same security group or user account saying to explicitly DENY the DELETE security.

This solution does NOT disallow DELETE this way

(WRONG)

This solution WILL explicitly DENY DELETE at this level to THIS FOLDER ONLY

(CORRECT)

(CORRECT)


Further Reading and Resources

  • ICACLS
2 of 2
0

This is not possible. You can make a folder to not be able to be deleted by removing modifying rights, but that will cause all files in that folder to automatically get that same right, making it impossible for people to work on new files in that folder.

You can create subfolders and disable inheritance of rights to make people able to work in those folders, but you should move the remaining folders into a subfolder or decide against doing this.

You can also give files different rights than their parent folder, but that would only allow people to edit existing files, including deleting them. But when they want to copy or create a new file in this folder they can't.

Also, please note that the filesystem you're suggesting is bad practice. You'll want to set the permission on a as high level as possible, setting inheritance to all subfiles. The reason is, that you can push rights down to all child folders. If this is done from a higher folder, all rights are removed.

But sufficient to say, it is not possible to make it so that a folder cannot be deleted/moved while its content can. If deletion is of a great concern to you, enable Volume Shadow Copy and optionally a backup. If a folder is moved, it will be moved inside VSS also. If deleted, you can simply undelete from VSS (restore previous versions). If moving is of a concern and you can't find where it was moved to, make a daily backup and of course, you can always try to instruct people to simply not delete/move these folders.

This kind of action is usually because people simply are not aware they are not supposed to move them, and delete by accident can be undone using VSS.

🌐
QNAP
qnap.com › en › how-to › faq › article › how-can-i-restrict-users-from-deleting-files-and-folders
How can I restrict users from deleting files and folders? | QNAP
January 4, 2023 - Click Add. The Edit Principal window opens. Configure account permissions. Under Type, select Deny. Select Delete subfolders and files. Select Delete (files only). ... The system restricts the user from deleting any data within the specific folder.
Top answer
1 of 1
1

Hi

as a starting point, I'm assuming the "Shared Drive" is the root drive thats mapped for all users via GPO, and you then have multiple departmental folders contained within that Shared Drive?

You need to go with the most restrictive approach that will also give your users functionality to perform their roles

My approach to this would be:

  • Create Security Groups in Active Directory for each group of users.
  • For Share Permissions on the Shared Folder, give each of the groups you created Full Control rights. Do not use "Everyone", "Domain Users" or "Authenticated Users".
  • For NTFS Permissions on the Shared Folder, give each of the groups you created Read and Execute rights to "This folder only".
  • For NTFS permissions under each subfolder, give each of the groups Modify rights at most to their respective folders and allow this for "This folder, subfolders and files". Never give Full Control, as this allows users to change permissions or add other users/groups to the NTFS permissions.

One thing to note on the NTFS permissions: you are likely top see "Authenticated Users" getting inherited "Read and Execute" access from the root folder on your server.

Click on "Disable inheritance", and select the option below (you'll still need Administrators, CREATOR OWNER and SYSTEM to have permissions):

You can then remove "Authenticated Users" and add your own set of permissions.

Hope this helps,

Thanks

Michael Durkan

  • If the reply was helpful please upvote and/or accept as answer as this helps others in the community with similar questions. Thanks!
🌐
Spiceworks Community
community.spiceworks.com › software & applications
Help me! how to prevent users deleting files/folders in 'SHARED NETWORK DRIVE' - Software & Applications - Spiceworks Community
December 10, 2016 - We have a shared network drive, that contains almost all the important data. I want to prevent users from deleting files/folders in that ‘SHARED NETWORK DRIVE’. I have WINDOWS 2008R2 running as Domain Controller Server. While the shared network drive is connected to a Windows Server 2012R2 ...
Top answer
1 of 4
3

The key is that users can delete a file if the file's ACL entitles them to delete it or the containing directory's ACL gives them the delete-child permission. You need to make sure that this limited user doesn't get either permission. On the special folder from which they shouldn't be able to delete files, assign them the following permissions in the Advanced Security Settings window:

  • Allow "traverse folder / execute file", "list folder / read data", "read attributes", "read extended attributes", "create files / write data", "create folders / append data", and "read permissions" on "this folder and subfolders"
  • Deny "delete subfolders and files", "delete", and "change permissions" on "this folder, subfolders, and files"
  • Allow full control on "files only" (this will be moderated by the previous deny rule)

But because this user is the owner of any files they create, they are entitled to change the permissions to allow deletion. The last piece of the puzzle is the arcane OWNER RIGHTS principal. You can type that phrase right into the user selection dialog where you would usually type the name of a user or group. Create one last rule on the folder that grants only "read permissions" on "subfolders and files only" to OWNER RIGHTS. Then the only advantage of being the owner of a file in that folder is that it guarantees ability to see the ACL, but not to change it.

2 of 4
2

Prevent NTFS Object Owners From Changing Permissions

If users access their data through a Windows network share, a system administrator can prevent the Owner of an NTFS file or folder from changing permissions by not granting the Full Control share permission:

Credit to this article for the concept.

Therefore, whatever permissions are granted to users in the first place will remain in effect, even for object owners, as they won't be able to exercise their ability as Owner to grant themselves permissions not permitted by the server administrator.

🌐
Seven Forums
sevenforums.com › general-discussion › 267391-possible-grant-full-access-except-delete-folders-files.html
Is it possible to grant full access except Delete on folders and files - Windows 7 Help Forums
December 2, 2012 - I have granted access to select files on my main account,... Windows says it won't grant access permission, but it does grant. in General Discussion I tried to take the following steps to get the "full control" permission on a "System Volume Information" folder for a user account I had created.