2

What I would like to do in my batch file is delete ALL the contents of the containing directory AND the directory itself. Currently I am using the following command:

rmdir ..\dir /S /Q & exit

This works in that it deletes ALL of the contents in dir including the batch file but it fails to delete the directory, dir. Is there a way to do this while deleting the dir also? Essentially what I would like to do is create a batch script that would reside inside a ZIP file and deletes everything that gets created from unzipping the file. The above command still leaves behind an empty directory.

user972276
  • 2,973
  • 9
  • 33
  • 46

1 Answers1

4

What about the following?

cd ..
rmdir .\dir /S /Q & exit

You can't delete a directory which is occupied by a running process.

Axel Kemper
  • 10,544
  • 2
  • 31
  • 54