I'm moving some files around on the server (Windows Server 2003), and there's a locked file that no one seems to have open. How do I delete this file?
Be careful with solutions which close the file handle, since they might cause unpredictable corruption. See technet.microsoft.com/en-us/magazine/… for details.– CesarBJul 29, 2009 at 17:51
Use the openfiles command to identify and disconnect users who have the file open. If that doesn't work, download the Unlocker utility.
openfiles.exe /query openfiles.exe /disconnect /id openFileID
the link above for the Unlocker utility doesn't work, but this one does - download.cnet.com/Unlocker/3000-2248_4-10493998.html– proJan 8, 2010 at 10:08
1Such a nice utility, too bad it's surrounded by so many "click here" links. Feb 14, 2012 at 20:28
1.) Open `computer management', (right-click "My Computer", select `Manage') 2.) Scroll down to `Shared Folders', expand. 3.) Select/click on `Open Files'. Double/triple-check to make sure nobody has it open.
If you're good on the above, a too-deep file/folder path might be giving you some grief. Try navigating several folders towards the root, then cutting and pasting them to reduce some of that path. Alternately, you could rename the folders in the path to "1", "2", "3", etc. Cutting down on some of the extraneous characters.
SysInternals has a tool called MoveFile that will do move or delete the file upon reboot of the machine.
I see this all the time, you can also run Systernal's Process Explorer to find who has the file, here's a great how-to on using Process Explorer for this purpose: Unlocking files that are in use
I personally like this way since I have this tool on my USB drive and can run it without having to install it.
+1 Unlike 'openfiles' this will show you local processes that have files locked, not just those locked from remote.– sysadmin1138 ♦Jun 3, 2009 at 19:13
openfiles /local on will show you local open files, however you will have to reboot if it's the first time you've had to do it.– Jim BJun 3, 2009 at 20:02
A few methods are here: http://www.geeksaresexy.net/2007/06/04/how-to-delete-an-undeletable-file/
As a last resort you can try booting up in "Safe Mode" or "Command Prompt" mode and deleting the file that way.
We see this a lot with viruses, spyware, etc. Booting up in safe mode usually does the trick.