Wednesday 17 October 2012

Unlocking files that are in use using ProcessExplorer

This morning builds started failing in our TFS 2010 server due to a file being in use. It turns out that the file was being used by the backup process, god knows why they were backing up the build area but that is by the by.

After a lot of recommendations about different software, I found this post, which suggests using Process Explorer from Sysinternals, which was exactly what I needed as it was already in the server.

In this example I just used PowerShell to create a new instance of StreamWriter, which writes to a file called test.txt, thus creating a locked file, but the idea is the same for any locked file. 
  1. Start Process Explorer.
  2. Press Ctrl + F to look for handles on files.
  3. Enter the name of the locked file.
  4. Double click on it, which will take you to the file handle itself.
  5. Right Click on it and select Close Handle
  6. Click Yes.

No comments:

Post a Comment