Unlock file on Windows Server 2003 by remote desktop without rebooting

16
2014-04
  • BalusC

    We've several Windows Server 2003 machines running, each with its own purposes. There are scheduled jobs which synchronizes some files over SFTP using WinSCP. Very sometimes a newly copied file is left locked in the "inbox" folder without any reason. The machine's own background task (programmed in Java) can't move it to the "processed" folder anymore after processing it.

    Manually moving it only yields the well known error message Cannot move [filename]: it is being used by another person or program.

    I tried Unlocker which works fine locally at WinXP, but doesn't work at those Win2K3 machines by remote desktop (unlock option doesn't show up in rightclick context menu). I tried Process Explorer as well as described in this blog article, but it caused the server to crash and reboot (not sure if that's because it's executed through remote desktop).

    The only resort is to reboot the machine, but we would of course like to avoid that. Any suggestions?

  • Answers
  • gravyface

    What happens if you restart the FileZilla Server service? You could exec net start/stop "FileZilla Server" service from your Java application if it fails to move the file.

  • sinping

    If the file was being held open by the kernel (System process) then killing the handle generally results in a blue screen, although not always.

    Typically closing the program that had it open will free up the lock. I'd suspect your Java application is at fault ultimately.

    These resources may be useful:

    Configuring opportunistic locking in Windows http://support.microsoft.com/kb/296264

    How Oplocks function in the Windows Environment http://msdn.microsoft.com/en-us/library/cc308441(v=MSDN.10).aspx


  • Related Question

    Windows File Sharing Orphaned File Locks
  • Sean Edwards

    Over the past few weeks the company I work for has been having issues on their server wherein a file gets locked by something, and can't be unlocked. These files are almost always files that are being actively accessed over Windows file sharing. I've downloaded the popular Unlocker program, but that is unable to find any lock on the file. openfiles.exe (or System Tools > Shared Folders > Open Files) does not show the file as being open by anything. Yet I'm unable to open it in anything, including notepad - the system gives me a permission denied error even when accessing the file as the local system administrator. The problem always goes away when the server is rebooted.

    To make matters worse, I've also been unable to reproduce this error at all. It's frequency is anywhere from daily to a week of working perfectly fine. When the problem does happen, I have very little time to investigate it, because nine times out of ten the problem makes our production systems completely nonfunctional, and management wants the server rebooted.

    The problem is also not limited to a single application. The majority of the file sharing traffic is in our production management software, Globalshop, so the problem usually manifests itself somewhere in there, however the most recent occurrence was in a Microsoft Access database completely separate from anything Globalshop.

    Has anyone seen anything like this? Any idea what could cause it? Let me know if there's any more information you need.

    We're currently running Windows Server 2003 Standard Edition.

    [edit] I've tried checking permissions, but I'm disallowed access to those as well on the offending file. I can't open, move, delete, rename or even copy the file.

    [edit2] I've managed to isolate two offending files. As long as no other production-interfering problems crop up, I've been authorized by management to keep the server online for the rest of the day to test them.

    [edit3] Brettski, in comments, suggested that I look at the file permissions. I've taken a screenshot of the properties window of one of the offending files. As you can see, there are no permissions available. http://i43.tinypic.com/24xgpe8.png (This is opened as the system administrator with full access rights.)


  • Related Answers
  • Evan Anderson

    Grab Handle.exe (http://technet.microsoft.com/en-us/sysinternals/bb896655.aspx) and, on the server computer, run a "handle -a" redirecting the output to a text file. Search that for the affected filename. That should at least tell you what process on the server computer has an open handle to the file. I'd be interested to know what process has a handle to it. (I'm wondering about anti-virus software as a possibility...)

    My condolences for having to deal with GlobalShop, BTW.

    Edit:

    McAfee VirusScan 8, eh? Have a look at this: https://kc.mcafee.com/corporate/index?page=content&id=KB52156

    It refers to Microsoft Office files, but it sounds suspiciously like it could affect any type of file. See also:

    http://forums.mcafeehelp.com/showthread.php?t=223545

    http://www.tek-tips.com/viewthread.cfm?qid=1453943&page=1

    http://techrepublic.com.com/5208-6230-0.html?forumID=101&threadID=207897&messageID=2632853

  • Jim B

    Procmon might be your best solution here as it is able to log what processes are using what files. Even if the file isn't showing up in openfiles procmon will log who opened it. Antivirus software is the usual culprit in these cases.

  • Ian Jacobs

    Unlocker seems to have potential. I haven't had a chance to try it yet though, so let me know how it works.

  • Area 51

    I have been having a similar problem on our file server (Windows Storage Server 2003 R2 x64). Only small temporary files (usually Access .ldb "lock" files, but also temp files used for various processes), no pattern on location or size or name or type. Files were locked with no access to permissions; unlocker programs (I was using EMCO UnLock IT, to which I will give a thumbs-up in passing) did not see any programs holding the files as locked. Rebooting always fixed the problem, but that was a major PITA with everyone having some files in use on that particular server.

    Based on comments here, I turned off our AV software on that server. Without rebooting, the file that was untouchable a moment ago vanished (it was a temp file that should have been deleted anyway, so this was A Good Thing).

    AV software is CA eTrust Antivirus v. 7.1. I'm guessing (with the aid of hindsight) that Old Software + x64 OS = Occasional Bad Things. :-)

    My thanks to Sean and Evan for the discussion.