How to delete Windows directories with cmd?

8k Views Asked by At

I'm playing around with hacking on my virtual machine and in that tried to delete a folder which Windows created by default - "Videos" or "Documents", etc.

I would like to delete that folder from the cmd (I tried as an admin) but it doesn't seem to work. When deleting it from the GUI there were no issues.

I tried the following:

rmdir /s /q folderpath

And always get: Access is denied

2

There are 2 best solutions below

1
Sinceris On

From this StackOverflow answer:

RMDIR or RD if you are using the classic Command Prompt (cmd.exe):

rd /s /q "path"

If it tells you you have no access/permission to remove the directory, it's most likely an important Windows directory you shouldn't remove. You could try opening the CMD as Administrator, but be sure to check that it's safe to delete the folder.

0
raja emani On

start cmd in admin mode

takeown /F C:\{folder-name}\* /R /A 
icacls C:\{folder-name}\*.* /T /grant administrators:F 
rmdir /S /Q C:\{folder-name}\