views:

1158

answers:

4

This problem crops up every now and then at work. Our build machine can have it's files accessed via a normal windows file share. If someone browses a folder remotely on the machine, and leaves the window open overnight, then the build fails (as it has done now). The explorer window left opened points at one of the sub folders in the source tree. The build deletes the source, and does a clean checkout before building. The delete is failing.

Right now, I'd like to get the build to work. I'm logged in from home, and I'd rather not reboot the build machine. I'm unable to get hold of the person whose machine is looking and the files, and I can't remotely reboot their machine.

When a windows share has a lock, the locking process is System, so I don't think I can kill it, as with normal locks.

Does anyone know a way to release the lock on a shared folder without having to reboot the machine?

+2  A: 

Have you tried this utility? I don't think this kills the process in order to break the lock on a file.

Phill Sacre
+1  A: 

Use Unlocker

shoosh
Looks like a great utility, but I refuse to install it on account of their spamware policy. They want donations on the web site, but when you install it you get prompted for the Bing toolbar (defaulted to yes). If I uncheck the box, it forces me to wait 30 seconds. WTF?! Cancel.
spoulson
+4  A: 

Found a solution.

  1. Find the process using Process Explorer:

    1. Download and extract procexp.exe
    2. In Process Explorer use the "Find Handle or DLL..." command from the "Find" menu
    3. Enter in the name of the directory which is having trouble deleting
    4. A list of open files which match that name should be shown. Take some guesses and find which one is failing to be deleted. If the file is locked by a windows share, the process holding the file will be System
    5. Note down the directory which was left open
  2. Download and install the Unlocker program unlocker1.8.7.exe

    1. Install Unlocker, disabling the option for Explorer extensions and other junk
  3. Unlock the directory

    1. Open up a cmd window, and navigate to C:\Program Files\Unlocker
    2. From the cmd window, run Unlocker.exe "the-path-to-the-locked-folder"
    3. A dialog will pop up confirming the lock release. Use the unlock button to unlock the file

Now the directory should be unlocked, and can now be deleted.

Jonathan Wright
A: 

you don't need anything. Just close the handle remotely with api

How? Which API? Example code?
Jonathan Wright