You must be an administrator to delete this folder work around for windows

Author: Steven Neiland
Published:

Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

Have you ever tried to delete a directory on windows or windows server and been blocked by the message that you must be an administrator to change this directory? I know I have many times.

What makes this message even more frustrating is when you are logged in as an administrator. There are reasons for this, but they really just don't make sense from a usability point of view. To say windows security system is a pain in the ass is an understatement.

RMDIR work around

The way I normally get around this is to delete the directory in question from the command prompt using the "rmdir" command.

First open a command prompt window with administrator privileges. To do this type cmd into the search box in your windows start menu. When the cmd.exe shortcut displays right click on it and select "Run as administrator".

Delete Empty Directory

From here type the "rmdir" command followed by the full path to the directory you want to delete.

rmdir c:\path\to\empty\directory

Note that this will only allow you to delete empty directories and will give you an error if there are any files or folders inside it.

Delete Non Empty Directory

To delete a non empty directory you must add the /S flag to the command like so.

rmdir /S c:\path\to\non\empty\directory

This will then prompt you if you are sure you want to delete this folder (Y/N). Enter Y and hit enter to confirm the delete.

If you wish to skip being asked for confirmation you can also add the /Q flag for quiet mode like this.

rmdir /Q /S c:\path\to\non\empty\directory

Compatibility

This command should work on all versions of windows based on the windows 2000 family: Windows 2000, Windows XP, Server, Vista, 7 and 8(not tested).

Reader Comments

  • Please keep comments on-topic.
  • Please do not post unrelated questions or large chunks of code.
  • Please do not engage in flaming/abusive behaviour.
  • Comments that contain advertisments or appear to be created for the purpose of link building, will not be published.

Archives Blog Listing