13

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?

1

6 Answers 6

18

Use the openfiles command to identify and disconnect users who have the file open. If that doesn't work, download the Unlocker utility.

Openfiles syntax:

openfiles.exe /query
openfiles.exe /disconnect /id openFileID
2
9
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.

3

SysInternals has a tool called MoveFile that will do move or delete the file upon reboot of the machine.

MoveFile link

2

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.

2
  • +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 B
    Jun 3, 2009 at 20:02
1

A few methods are here: http://www.geeksaresexy.net/2007/06/04/how-to-delete-an-undeletable-file/

1

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.

Good luck!

You must log in to answer this question.