Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone have a good script that will delete an old, non-booting, inactive Windows directory from the command-line?

share|improve this question
up vote 5 down vote accepted


rd /s /q <directory name>

From a CMD command prompt.

How's that work for you?


Okay-- how about:

takeown /F <directory name> /R /D Y
cacls <directory name> /T /G Everyone:F
rd /s /q <directory name>

Should be run from an elevated command-prompt.

share|improve this answer
It doesn't work because it doesn't address the various permissions and results in access denied on many files. I was playing around with something with taking ownership, then changing the permissions, and then deleting, but it doesn't seem to always work. – NoahD Jul 8 '09 at 18:27
I had a switch wrong, thanks!! – NoahD Jul 8 '09 at 20:28

Not sure what OS you are running, but if it is Vista, instructions on deleting the windows.old directory can be found here: or (they pretty much say the same thing).

Edit: I see in the subject line that it is Vista... Those KB articles should do the trick.

share|improve this answer

Your Answer


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.