4

So if you want a windows command prompt open and its CWD is say, "C:\xyzzy\", and you attempt to delete the directory c:\xyzzy somewhere else, the delete will fail.

Most unix shells don't block deletion of the CWD like this.

We have automation that installs and deletes stuff and is always getting foiled by things like a command prompt sitting on a directory.

Is there anyway to tell windows "delete this directory, I don't care who has open files in it"?

It would be nice if this were a system setting.

1 Answer 1

5

No, you cannot. It's simply a difference between Unix and Windows – the former allows deletion of open files, the latter does not. There is no system setting for this. The only thing you can do is forcefully close the open handles (see Unlocker) or to entirely kill the process that has them open.

3
  • Unlocker looks pretty good, actually. I'll look into adding it to our automation. Thank you.
    – marathon
    Oct 20, 2011 at 0:48
  • 2
    Actually, Win32 does allow deletion of open files, provided that the prior opener(s) chose to open them in FILE_SHARE_DELETE mode.
    – JdeBP
    Oct 21, 2011 at 0:15
  • Which the current directory is not, unfortunately. Oct 21, 2011 at 12:52

You must log in to answer this question.

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