Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

(Inb4 "Windows sucks" statements, the Unix behavior does offer its complications as well, such as unclean reboots possibly resulting in the inode and data still allocated, but not reachable in any way. Thus the auto-fsck on every boot.)

share|improve this answer
    
Unlocker looks pretty good, actually. I'll look into adding it to our automation. Thank you. –  marathon Oct 20 '11 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 '11 at 0:15
    
Which the current directory is not, unfortunately. –  grawity Oct 21 '11 at 12:52

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.