Coping With Windows File Locking

I’ve run into this problem more times than I’d like to admit:

C:\>del foo.txt
The process cannot access the file because
it is being used by another process.

Umm, right, thanks. So should I just start killing processes indiscriminately? Perhaps now would be a good time for my daily sacrifice to the reboot gods?

Turns out there is a better way. I am not sure how I got this far without discovering handle.exe from SysInternals Microsoft:

C:\>handle foo.txt

Handle v3.2 (64-bit)
Copyright (C) 1997-2006 Mark Russinovich
Sysinternals - www.sysinternals.com

evil.exe            pid: 6044     68: C:\foo.txt

Now I know exactly which process to kill with extreme prejudice.

Advertisements

1 Response to “Coping With Windows File Locking”


  1. 1 jfb January 30, 2008 at 3:13 pm

    Even better, you can use Process Explorer to search for the file handle and close only the handle instead of killing the entire application. The application might malfunction later, or it might not, but killing only the handle is less drastic than killing the entire process.


Comments are currently closed.




%d bloggers like this: