3

Command prompt:

CD C:\Users\Example\

rmdir favorites

Access is denied.

How do I delete the Favorites folder via the command prompt?

  • Yes, I want to do this.
  • Yes, I know this folder is for Internet Explorer.
  • Yes, I manually delete this folder all of the time without any issues.
  • No, the My Documents folder is my folder, not Microsoft's.

Edit 1:

I added "Everyone" as a user with all permissions for S&G:

Folder Permissions

Edit 2:

icacls Favorites
Favorites S-1-15-3-4096:(OI)(CI)(RX,W,DC)
          Everyone:(I)(OI)(CI)(F)
          NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F)
          DESKTOP-DM38CA6\John:(I)(OI)(CI)(F)
          BUILTIN\Administrators:(I)(OI)(CI)(F)
          Mandatory Label\Low Mandatory Level:(OI)(CI)(NW)

Successfully processed 1 files; Failed processing 0 files

Answer

Thanks to people's comments and S. Brottes's answer here are the batch commands:

cd C:\Users\Example\Favorites
attrib desktop.ini -h -s
del desktop.ini
cd..
rmdir /s /q favorites
10
  • 1
    Are you logging-in as the user that owns the folder, or at least as administrator? Is CMD run as Administrator?
    – harrymc
    Commented Sep 13, 2022 at 8:27
  • @harrymc I always run local admin accounts for Windows. Also I tested the admin permissions command prompt and same issue.
    – John
    Commented Sep 13, 2022 at 11:56
  • Could you add a screenshot of the Security tab after right-click in Explorer of the folder and selecting Properties?
    – harrymc
    Commented Sep 13, 2022 at 12:43
  • @harrymc Which folder? C:\Users\Example\?
    – John
    Commented Sep 13, 2022 at 13:53
  • 1
    Have you tried rmdir /s favorites?
    – harrymc
    Commented Sep 13, 2022 at 15:48

1 Answer 1

3

Some default folder like "Favorites" have "Read Only" attributes.

You can check the attributes with the following command

attrib Favorites

This attribute prevents to delete the folder.

You can remove the read only attribute with the following command :

attrib -R Favorites

Then you should be able to remove the directory with the rmdir command.

The folder must be empty, or you must use the /s param to delete all elements of the folder.

3
  • 1
    Cool, after using attrib -R Favorites then rmdir favorites resulted in "The directory is not empty.". Unhide system files and there is a desktop.ini file (for the custom folder icon). I used attrib desktop.ini -h to unhide and it returned "Not resetting system file". I'll post the full working answer though because I figured it from you I'll accept yours.
    – John
    Commented Sep 13, 2022 at 16:22
  • 1
    When files have System attribute AND Hidden attribute, you must remove the two attributes in the same time in order to make it work. You can use the following command: attrib -h -s <filename>
    – S. Brottes
    Commented Sep 13, 2022 at 16:33
  • I should note that rmdir /s /q C:\Users\John\Favorites the two switches are necessary for the automated batch whereas everything else works perfectly during a manual command prompt.
    – John
    Commented Oct 3, 2022 at 0:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .