Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a windows equivalent of sudo rm -r [directory-name]?

share|improve this question

2 Answers

up vote 33 down vote accepted

deltree if I remember my DOS.


It seems it's been updated... this is what you want:

RMDIR /S

This removes the directory C:\test, with prompts :

rmdir c:\test /s

This does the same, without prompts :

rmdir c:\test /s /q

Regarding the sudo part of your question, if you need more priviliges, you can first open a new shell as another user account using the runas command, like this:

runas /user:Administrator cmd
rmdir c:\test /s /q
share|improve this answer
hmm . . . doesn't work for me. – Eric Wilson Aug 23 '10 at 19:32
1  
@FarmBoy, apologies, it would seem my memories go far too far back. I've updated the answer for Windows XP and newer. – Colin Pickard Aug 23 '10 at 19:36
yes deltree is an old DOS command. It was removed in XP and replaced by rmdir /s – heavyd Aug 23 '10 at 19:39

If you want to delete a long and complicated folder structure from the command prompt that RmDir won't touch and not even explorer can display, I've found robocopy can be very efficient at removing the structure. In the example below we have a massive structure inside the folder administrator, the structure is so deep that nothing can remove it. We create a new empty folder called (strangely enough!) "new folder". We then use the robocopy command, telling it the source folder is "new folder" and the destination folder is "D:\Administrator" with the /MIR parameter which means it will purge anything not in the source folder.

robocopy "D:\new folder" D:\Administrator /MIR

In this case the folder paths were so long they would not even fit in the command prompt window Screen Buffer, but Robocopy will traverse the structure and remove any "extra" files and folders (ie anything not in the new empty folder, which is everything).

share|improve this answer
This is the only solution that will work when your path is more than 250 odd chars long – Calm Storm Feb 12 at 16:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.