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.

I have several executables in different directories that are hard links to the same data.

.
|-- file 1
`-- cache
    `-- foo.exe
`-- bar
    `-- foo.exe <-hard link to .\cache\foo.exe
`-- baz
    `-- foo.exe <-hard link to .\cache\foo.exe

If one of these is currently running, I can not delete the others. I execute .\bar\foo.exe and then try to delete .\baz\foo.exe I am told that the file can not be deleted. Killing the .\bar\foo.exe process is not feasible, as it is a long running and expensive task. But I really need .\baz\foo.exe gone, because I need the name for something else.

is there a way to break the link and get rid of .\baz\foo.exe?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

You can rename baz\foo.exe (for example, to deleteme.exe), then delete it after the process exits.

You can move the file elsewhere too, as long as it stays within the same filesystem. (Within a single filesystem, renaming and moving are almost the same thing.)

share|improve this answer
    
Thanks. That seemed to work. I can have my cleanup script sweep un-delete-ables into a junk dir, and clean them up later. –  Matthew Scouten Jun 27 '11 at 19:16
add comment

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.