Unlocking files that are in use

by Shijaz Abdulla on 22.10.2008 at 21:20

Sometimes you cannot delete or rename a file that is currently in use. You might receive an access violation error, or simply a message telling you that your action could not be completed because the file is open in another program.

image

You may have already come across the Unlocker freeware tool that lets you "unlock" files that are in use by some application.

Here is another way (let’s call it the ‘techie’ way) to unlock files that are in use. It makes use of the Process Explorer tool from Windows SysInternals.

  • Download the Process Explorer tool. Execute procexp.exe
  • Choose Find > Find Handle or DLL option

image

  • Type the name of the file you want to unlock and hit Search.

image

  • The process EXE locking the file and the path to the file are listed. Double click on the result.

image

  • The file handle will be highlighted. Right-click on it and choose Close Handle.

Your file is now unlocked and can now be deleted, moved or renamed.

A little disclaimer here, closing handles might cause data inconsistency, loss and/or other undesirable effects. Make sure you understand what you’re doing before you do it.


About Shijaz Abdulla

facebooktwitterlinkedin

Shijaz Abdulla is a Datacenter Technology Solutions Professional at Microsoft, based in Doha - Qatar and helping customers better manage their infrastructure using Microsoft technologies. He is a blogger and a technology enthusiast.


Trackback Permanent Link

22 Responses to Unlocking files that are in use

  1. EhabT says:

    me no like the ‘techie’ way…
    i preffer the ‘easy’ way …
    just use KillBox from
    http://www.killbox.net
    easy to use, no installation (i have it on my flash drive everywhere i go) and best thing, it can kill any file or any process with 2 clicks (literally)

    cheers
    EhabT

  2. Roger Pack says:

    use unlocker and right click on it :)

  3. David says:

    This was GREAT… cause when I ran it on 2003 srvr at work, and typed in the name of the file after clicking on find, it locked up the entire server so badly even a ctrl-alt-del wouldn’t work.

    Hit the big red switch…

    So, way to go, Microsoft! Thanks for the helpful tip!

    • Shijaz says:

      Hi David,

      Of course you understand that this is a personal blog and not affiliated or maintained by Microsoft in any way. Read the disclaimer.
      The Unlocker tool here is also not from Microsoft. It is a third party tool!

      Thanks :)

      Shijaz

  4. Chandra says:

    Wow, Good I trying to delete the file that is in use. I downloaded ProcessExplorer but dont know how to use the tool. Your article helped me a lot. Anyway Thanks !!!!!!!!!

  5. sm says:

    tried unlocker on a file, though it unlocked the haldes, couldnt delete still. tried this and it did.

    if you cant follow the instructions after downloading process exp you should not be near a computer.

  6. Pingback: Unlock file on Windows Server 2003 by remote desktop without rebooting Drija

  7. Pingback: Unlock file on Windows Server 2003 by remote desktop without rebooting

  8. Stavros E says:

    Very helpful article,

    used with success in win 2008 environment.

    Than you

  9. Shahryar Ali says:

    Perfect – the whole process was done in about a minute, including the download.

    Very useful, Shijaz, thanks for the help.

  10. Rob C says:

    I use Process Explorer all the time for more than just unlocking files – it can also tell you which program/process is eating up all of your CPU, kill processes that have locked up, etc.

    I have trouble trusting the small, third-party apps – this one’s from Microsoft and is rock solid.

  11. Tanya says:

    I tried this with a terminal server locked profile, the user had been offline for an 1hr while I tried to rename the corupt profile. Still cannot rename the users folder. They are get a temp profile when they log in as their profile is bad.

    Any idea’s

  12. Tanya says:

    It’s mainly the NTUser.dat and the NTuser.dat.log files that are locking, which is preventing me from deleting/renameing the profile folder on the 2003 Terminal server.

  13. Bill says:

    I have a nasty debugging issue, and this has proven to be very helpful. Thanks, and just ignore the haters!

  14. Binu says:

    I have used process explorer but my attempt to find and delete the left over temp file *.VSP related to Veritas Netbackup was not successful, process explorer just couldnt see the file ( file was not hidden ;-) ). The file was in Gigs and monitoring system was throwing low disk space alerts. Have to see if unlocker or killbox will be of any help.

  15. Luiz F Silva says:

    Hello Shijaz Abdulla, I´m from Brazil and would like to thank you for your help on it. really tried find any document showing how this process works and never find. Really appreciate if you could to create more document also this one. Get the Sysinternal tools and let us know how we can use.

    Bye

  16. bob says:

    procexp couldn’t find the file that was ‘in use’ unlocker got rid of it in a couple of clicks

  17. halek says:

    Re-boot using a Linux live CD (I use Puppy Linux). You can then delete any file you like.

  18. RT @shijaz: Unlocking files that are in use http://t.co/13Yl3d3r

  19. Pingback: Unlocking files that are in use. | Nathan Totten

Leave a Reply

Your email address will not be published. Required fields are marked *

Connect with Facebook

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>