How do you force delete a folder using CMD Access Denied?

When attempting to delete a folder in Windows using the Command Prompt, you may encounter an “Access Denied” error. This occurs when you don’t have sufficient permissions to delete the folder.

It’s important to understand how to solve this issue, as it’s a common problem that can prevent you from managing files and folders on your system. This article will provide an overview of what the error means, how folder permissions work, and step-by-step methods to delete a folder you don’t have access to.

We’ll cover checking permissions, taking ownership, granting yourself full control, disabling inherited permissions, and using the “rmdir” command. Alternative methods like booting into Safe Mode will also be discussed. Following these steps will allow you to force delete restricted folders in Windows using the Command Prompt.

What Does the Error Mean?

The “Access denied” error when trying to delete a folder using the Command Prompt indicates that your user account does not have sufficient permissions to delete the folder. This is due to the permissions system in Windows called NTFS (NT File System).

NTFS allows settings permissions on files and folders to control access. Permissions include the ability to read, write/modify, delete, etc. By default, users can only modify files or folders they have created themselves in their own user directory. Deleting other folders requires elevated permissions.

So if you receive an “Access denied” error when running the del or rmdir command on a folder, it means your user account lacks the NTFS permissions to delete that folder. You will need to modify the permissions first before being able to delete the folder via CMD.

Check Folder Permissions

If you receive the “Access is denied” error when trying to delete a folder in CMD, the first step is to check the folder’s permissions to see if your user account actually has delete rights.

You can view folder permissions from File Explorer by right clicking on the folder, selecting “Properties”, and then clicking the “Security” tab. Look for your username in the list and see if the “Delete” permission is checked.

Another way to check permissions is by using the cacls command in CMD. To list permissions for a folder, navigate to the parent folder in CMD and type:

This will display the ACL (access control list) for that folder, showing which users and groups have access and what permissions they have. Check if your account has the “D” permission listed, which allows deletion of the folder. If not, you’ll need to update the permissions before deleting.

For example:


Take Ownership of the Folder

One way to gain access to a folder that you are denied access to is by taking ownership of the folder using the takeown command in Command Prompt. The takeown command allows you to take ownership of the specified folder and gain full control permissions.

To take ownership of a folder such as C:\FolderName, type the following command in an elevated Command Prompt window:

takeown /f C:\FolderName /r /d y

The /f parameter specifies the folder path, /r makes it recursive to take ownership of all subfolders and files, and /d y suppresses the confirmation prompt.

Once executed, this gives you full control permissions over the folder and allows you to delete it or modify its permissions as needed without getting the “Access denied” error. The key benefit of using takeown is that it overrides any existing permissions and gives you owner access no matter what restrictions were in place before. This makes it a powerful tool for recovering access to restricted folders and regaining control.

For more details on the takeown command, see the Microsoft documentation here:

Grant Yourself Full Control Permissions

Another option is to use the icacls command to directly grant your user account Full Control permissions on the folder. This overrides any inherited permissions from parent folders. Here’s the syntax:

icacls “folderpath” /grant “Username”:(F)

For example:

icacls “C:\Foldername” /grant “MyUser”:(F)

This will grant the user account “MyUser” full control of the folder C:\Foldername, overriding any inherited permissions. The /grant parameter allows you to specify the permission level, in this case (F) for Full Control. Now you should be able to delete the folder without the Access Denied error [1].

Be careful when using icacls to grant full control permissions, as this gives that user account unrestricted access to that folder. Only do this temporarily to resolve the specific permission issue if needed.

Disable Inherited Permissions

One way to gain more direct control over a folder’s permissions is to disable inherited permissions from its parent folder. This can be done using the /reset switch on the icacls command.

According to How to reset NTFS permissions with ICACLS, “Then launch the command ICACLS * /T /Q /C /RESET. ICACLS will reset the permissions of all the folders, files and subfolders.”

What this does is replace the current permissions on the folder and its contents with only the default inherited permissions from the parent folder. So it removes any extra permissions that may have been set.

Once inherited permissions are reset, you can then modify the permissions directly on that folder without interference from the parent folder’s settings.

This gives you full control to grant or restrict access as needed on that specific folder. Just be aware that any new subfolders within it will inherit permissions from the folder you reset, not the original parent.

Delete the Folder

Once you have taken ownership of the folder and granted yourself full control permissions, you can now delete the folder using the rd (remove directory) or rmdir (remove directory) command in CMD.

The basic syntax is:

rd /s /q folder_path


rmdir /s /q folder_path

The /s switch deletes the specified folder and all its subdirectories. The /q switch suppresses confirmation prompts.

For example, to delete a folder called TestFolder on your C: drive, you would run:

rd /s /q C:\TestFolder


rmdir /s /q C:\TestFolder

This will delete TestFolder and all its contents without asking for confirmation. Be very careful when using the /q switch, as it will perform the deletion without any prompts.

Once you have resolved the permissions issues, the rd or rmdir command will be able to successfully delete the protected folder and its contents.1

Alternative Methods

If the standard methods for deleting a folder with access denied errors don’t work, there are some alternative approaches you can try:

One method is to take ownership of the parent folder and disable inheritance. To do this, right-click the parent folder, select Properties > Security tab > Advanced > Owner. Change the owner to your username, then uncheck “Replace owner on subcontainers and objects.” This will make you the owner of the parent folder without changing ownership of the subfolders. Then disable inheritance on the subfolder by unchecking “Include inheritable permissions from this object’s parent.” Now you can delete the subfolder even with the access denied error.

Another alternative is using PowerShell’s Remove-Item cmdlet with the -Force parameter. Open PowerShell and run:

Remove-Item -Path “C:\FolderPath” -Recurse -Force

The -Recurse parameter will delete subfolders and files, while -Force will force delete the folder regardless of permissions errors. This can help delete stuck folders when other methods fail.

Just be cautious when force deleting folders, as you may unintentionally remove important files without recourse. But when used judiciously, these alternatives provide additional options for dealing with denied access.

Avoiding Permission Issues

The best way to avoid “Access Denied” errors when trying to delete folders in Windows is to set permissions properly from the start. According to NTFS Permissions Management Best Practices, you should always grant permissions to groups, not individual users. Create groups such as “Finance Department” and assign folder permissions to the group. Then add users to the appropriate groups to inherit the permissions.

Also, grant explicit permissions rather than relying on inherited permissions from the parent folder. As NTFS Permissions: Best Practices for Your File Server! explains, inherited permissions can lead to issues down the road if permissions on parent folders change.

When creating shares, assign share permissions separately from NTFS permissions. Share permissions regulate who can access the share while NTFS regulates what they can do to the files and folders. According to 10 NTFS Permissions Management Best Practices, using both gives you an extra layer of security.

Finally, avoid logging in as an administrator account for everyday tasks. Administrator accounts bypass most permission checks, which is why folders may seem deletable but then you get “Access Denied” with a standard user account. Only use admin accounts when absolutely necessary. Set up folders and permissions properly from the start with a standard account.


In summary, the “Access Denied” error when trying to delete a folder in CMD indicates that your user account lacks the necessary permissions. To resolve this, you first need to check the folder permissions and confirm you don’t have full control. If not, take ownership of the folder and grant yourself full control permissions. You can also disable inherited permissions from the parent folder as an extra step. With the right permissions in place, you should then be able to delete the folder using the RD or DEL command in CMD.

The key steps to fix the “Access Denied” error when deleting a folder in CMD are:

  1. Check the folder permissions
  2. Take ownership of the folder
  3. Grant yourself full control permissions
  4. Disable inherited permissions from the parent folder
  5. Use the RD or DEL command to delete the folder

Following these steps will allow you to force delete folders in CMD that you previously did not have permission to remove. Just be cautious when taking ownership and modifying permissions, as this can impact access for other users. Overall, understanding permissions is crucial for resolving “Access Denied” errors in CMD and taking control of folders.

Leave a Comment