The Definitive 'Locked File' Post (updated 7/7/2014)


Any veteran of Excel has probably seen the error very similar to the one below:


  File in Use
  Tester123.xlsx is locked for editing

  by 'another user'.
 
Open 'Read-Only' or, click 'Notify' to open read-only and receive notification when the document is no longer in use.


Example:

Dealing with this can give anyone a major headache as it's often random and hard to reproduce at will. What makes resolving this particular problem difficult is that there are multiple causes for the problem, and thus multiple solutions. This article attempts to break the file locking problem down categorically so that it's easy to diagnose and fix. However, please understand that while I promise that I'd love to provide you with a fantastic list of everything that could ever fix this issue, I can't. Due to the many different environment configurations, as well as various software and hardware that can be involved, these steps may not work to resolve your issue or resolve your issue with a 100% success rate. These are only some suggestions for some of the most common things to look for and steps to try.

 

Things to do to resolve the problem

I. Ensure these rollup and updates for Windows are installed

Install the update in the following rollup and then install the three updates referenced in the rollup article (total of four updates).

Note: Before installing these updates you must first install SP1 for Windows 7 or Windows 2008 R2 (http://support.microsoft.com/kb/976932).

Rollup article:

"An enterprise hotfix rollup is available for Windows 7 SP1 and Windows Server 2008 R2 SP1"
http://support.microsoft.com/kb/2775511/EN-US

These are the individual links to the 4 updates to install. You do not need the reg keys mentioned in the article as they are for the specific issues listed with the reg keys which is unrelated.

Update for Windows Server 2008 R2 for Itanium-based Systems (KB2775511)
http://catalog.update.microsoft.com/v7/site/Search.aspx?q=2775511

Update for Windows 7 (KB2732673)

http://catalog.update.microsoft.com/v7/site/Search.aspx?q=2732673


Update for Windows 7 for x64-based Systems (KB2728738)

http://catalog.update.microsoft.com/v7/site/Search.aspx?q=2728738


Update for Windows Server 2008 R2 x64 Edition (KB2878378)

http://catalog.update.microsoft.com/v7/site/Search.aspx?q=2878378

 

II. Install the latest Updates for Excel and/or Office

This is where you go to find cumulative updates that are available from the Microsoft Office team to fix reported problems:

https://technet.microsoft.com/library/dn789213

 

III. Turn off the Preview Pane, Details Pane and pop ups that show information about file and desktop items 

 

This is a problem that has been reported to affect Windows 7 clients only, not Windows XP. This has been found to be an issue for which both Office and Windows have released updates for. However, while much less frequent, we've seen occurrences where this step may still help. If you are fully updated for both Office and Windows, and can find no other reason or resolution to this issue but this does help, this may be your only solution.

In a Windows Explorer window, do the following:

 

1. Right click on the Start Button.
2. Click 'Open Windows Explorer'.
3. At the top left click Organize > Layout 
4. Uncheck Details Pane and Preview Pane.

5. On a Windows menu, click on Tools > Folder Options.  In the box that opens up, click on the View tab.  Scroll down the list to “Show pop-up description for folder and desktop items” and clear the checkbox and then click OK. 

In Excel:

1. Click File > Open
2. Click Organize > Layout

3. Uncheck 'Details Pane' and 'Preview Pane'

If Outlook is involved:

1. Open a new e-mail.
2. In the "Include" group, click Attach File.
3. Click Organize > Layout 
4. Uncheck 'Details Pane' and 'Preview Pane'.

IV. Add the OpLocks registry keys

Add the following two registry keys to the client machines and then reboot the system:

Key: HKEY_CLASSES_ROOT\CLSID\{993BE281-6695-4BA5-8A2A-7AACBFAAB69E}
Name: EnableShareDenyNone 
Type: REG_DWORD 
Value: 1

Key: HKEY_CLASSES_ROOT\CLSID\{993BE281-6695-4BA5-8A2A-7AACBFAAB69E}
Name: NoOpLock
Type: REG_DWORD 
Value: 1

Note: Both of the above keys must be added for this solution to work.

V. Install operating system updates

1. For Windows 7, Windows 7 Sp1, Windows Server 2008 R2 or Windows Server 2008 R2 SP1 –

"ERROR_SHARING_VIOLATION" error message in Windows XP or in Windows Server 2003 when you try to open a file on an SMB share on a server that is running Windows 7 or Windows Server 2008 R2"

http://support.microsoft.com/kb/2625434

2. For Windows 7, Windows Server 2008 R2

"Temporary files do not synchronize correctly to a non-DFS share on a server from a client computer that is running Windows 7 or Windows Server 2008 R2"

http://support.microsoft.com/kb/2434932

3. For Windows 7, Windows 7 Sp1, Windows Server 2008 R2 or Windows Server 2008 R2 SP1 –

"You cannot access a shared file by using the SMB Version 2 protocol because of a race condition in Windows Server 2008 R2 or in Windows 7"

http://support.microsoft.com/kb/2618190

4. Windows Vista, Windows Server 2008 –

"You share some files on a computer that is running Windows Server 2008 or Windows Vista. Some users try to access these shared files. In this scenario, the computer may restart unexpectedly. Additionally, you receive a Stop error that resembles the following: STOP 0x0000004E (0x0000009A,parameter2, parameter3, parameter4 )PFN_LIST_CORRUPT"

http://support.microsoft.com/default.aspx?scid=kb;EN-US;2447725

5. Windows Server 2003 –

"You have a shared file on a computer that is running Windows Server 2003, Two applications access this shared file concurrently. One application has write access to the file, and the other application has read-only access to the file.After both applications run for some time, such as several hours, the application that has write access cannot write data to the shared file, and this application receives the "Delayed Write Failed" error message. This problem causes data loss or data corruption in the shared file."

http://support.microsoft.com/kb/971295

VI. Use MSConfig to stop third party programs and services, including antivirus software

1. Go to START, and from the RUN line, type MSCONFIG and hit ENTER.
2. The System Configuration Utility will launch. On the General tab, click the Selective Startup option. Then uncheck the boxes labeled "Load Startup Items" and "Load System Services".
3. Click on the Services tab. Find the column header at the top labeled "Service" and left click that column header to sort these services in alphabetical order. Scroll down in the list and find a service called "Windows Installer" and click it so that it has a check in the square box.
4. Click Apply and when the changes are made, the OK button will read "Close". Click this button and you will asked to reboot the machine.
5. After the machine has restarted, click OK when the System Configuration Utility information dialog appears. If the System Configuration Utility itself appears, click the red X at the top right corner of the dialog box. If you are prompted to restart the machine, click the button labeled "Exit Without Restart".

This should get the machine into a state where third party and non essential programs are not started when the computer boots. This includes anti-virus software. Try accessing shared files with these programs shut off.

To get the machine back to Normal mode, open MSConfig again as in Step 1 and on the General tab click the

“Normal” startup option. Click Apply, the Close and reboot the machine.

In cases where the wrong user name is displayed in the file lock dialog

Sometimes where it says 'another user' it has the name of someone that didn't open the file or it has no name at all. Just a big ' ' where a name ought to be. Fear not, there is a fix for this problem. The flavor depends on whether you have Excel 2010 or Excel 2007. The below KB Articles contain hotfixes that address several issues, not just the file locked issue. But in the dialog of the article you will see this as one of the problem descriptions:
 
Assume that you have an .xls file that is protected by Information Rights Management (IRM) on a network share. When you open the file in Excel 2007, a File In Use dialog box appears. However, the dialog box does not display the correct name of the user who locked the file. Therefore, you cannot edit the file.
 
Understand that these fixes don't make the File in Use dialog go away, they just correct the problem of showing bogus user name information on the dialog itself.
 
Excel 2007 – http://support.microsoft.com/kb/2598133
 
Excel 2010 – http://support.microsoft.com/kb/2598143

 

Additionally, we have seen this issue when the owner file is not deleted from the directory upon closing the file. The file looks like ~file name.xlsx and contains the user information for who had the file open. . This can happen if something interrupts the process and breaks Excels connection with the file.

An example of this would be if a user had the file open from a server and the server was then rebooted. This causes the connection between the Excel application and the owner file to be broken. When the user then closes the file, Excel does not see the need to remove the owner file from the directory, and this results in the orphaned file. When another user later tries to open the same file from that same directory with the orphaned (~filename.xlsx) file, Excel refers to the existing owner file for the information to present to the user in the file locked dialog, resulting in the incorrect user information being presented. To resolve this issue, you need only to delete the orphaned ~filename.xlsx file from the directory.

 

Considerations for NetApps storage devices

Note: If the issue is only occurring when using a NetApp or other third party storage, we would recommend engaging the Support Team for the third party technology for additional troubleshooting and assistance.

We have seen cases involving the file locking issue when moving files to a NetApps storage device. First and foremost – update your NetApps device to the latest version. The file locking problems can be fixed just by updating the NetApps device to the latest version. If that fails or if you have the latest version, there are a couple of other things to try. This information was documented at http://netappsky.com/netapp-storage-management/cifs-performance-is-slow-after-investigating-performance-issues-cifs-considerations/ but has since been taken down.

I. Enable oplocks

Make sure that cifs.oplocks.enable is on. Oplocks (opportunistic locks) enable a CIFS client in certain file-sharing scenarios to perform client-side caching of read-ahead, write-behind, and lock information. A client can then read from or write to a file without regularly reminding the server that it needs access to the file in question. This improves performance by reducing network traffic. CIFS oplocks on the filer are on.  By default: You might turn CIFS oplocks off under the following circumstances otherwise, you can leave CIFS oplocks on. 
 
1. You are using a database application whose documentation recommends that oplocks be turned off.
2. The CIFS clients are on an unreliable network.
3. You are handling critical data and you cannot afford even the slightest data loss.
 
sasfiler*> options cifs.oplocks.enable on
 
Make sure that this option is set before the clients connect to the filer.   If they are already connected, do a cifs terminate and cifs restart on the filer.
 
sasfiler*> options cifs.neg_buf_size 33028

II. Set cifs.oplocks_opendelta

Change the cifs.oplocks_opendelta setting. Under certain workloads setting cifs.oplocks_opendelta to 0 can improve CIFS throughput performance by 3% to 5%. Again, if setting this value to 0 results in client disconnects, reset it to 8 (the default value).  Changing the delay time for sending oplock breaks.  If a client that owns a file oplock sends a file open request, it is temporarily vulnerable to a “race condition” that can occur if the storage system requests an oplock break. To prevent this condition, the storage system delays sending an oplock break according to the delay time value (in milliseconds) specified by the cifs.oplocks.opendelta option.   By default, the default delay time is 0 milliseconds. If your storage system must support some older Microsoft Windows clients, including Microsoft you can set the delay time to another value, such as 8. This means that after the storage system receives or responds to a request to open a file, the storage system will make sure that 8 milliseconds have elapsed before sending an oplock break to that client.   options cifs.oplocks.opendelta time Here, time is the delay in milliseconds.  Setting the cifs.oplocks.opendelta option postpones the sending of oplock break requests to clients that have just opened files. You must consult technical support if you are considering setting this value higher than 35.

sasfiler*> options cifs.oplocks_opendelta 0

sasfiler*> options cifs.oplocks_opendelta 8

For example, try adjusting cifs.oplocks_opendelta to a value of 66 (milliseconds)

You might also want to increase the delay time for sending oplock breaks if you see syslog messages similar to the following:

Mon Jan 21 15:18:38 PST [CIFSAdmin:warning]: oplock break timed out to station JOHN-PC for file \\FILER\share\subdir\file.txt

Considerations for Shared Workbooks 

The primary feature of a shared workbook is to allow multiple users to open and edit the files simultaneously. However, if you have chosen to share your workbooks using the 'Share Workbook' feature in the Review ribbon, you may still experience this type of behavior in particular scenarios due to the way in which Excel opens and saves files.

Examples of scenarios that users may experience a similar message using a [Shared] Excel file simultaneously:

Scenario 1:  User 1 opens the [shared] file. User 2 also opens the [shared] file at the same time as User 1. 
       Result:  A "file is locked" type of message will be provided. 
       Workaround:  An option to "Notify" the user when the file is no longer locked is presented. Choose this option and when the lock is released, the user will be able to then choose to open the file in edit mode. 

Scenario 2:  User 1 saves the [shared] file. User 2 also saves the [shared] file at the same time as User 1. 
       Result:  A "file is locked" or "file is locked, try again later" type of message will be provided. 
       Workaround:  Wait a short period of time to allow the lock to release and try saving the file again.  

 

Flowchart

The following is a flowchart put together by Kevin Sickler on the Microsoft Excel Support team. It gives direction to this complex issue. Click the picture below to see a larger view:

 

 

Comments (37)

  1. Anonymous says:

    Nothing is actually locking the Excel file itself. It's the temp file that gets accessed by any number of programs, including third party programs. This KB Article might help:

    Description of the way that Excel saves files

    support.microsoft.com/…/814068

  2. RuslanKh says:

    When I open Excel file by double click on the file name I’ve the same error message. In my case the problem is that the owner file (~filename.xlsx) is not created because of some reasons. But I’ve found a workaround. If I right click on the file and choose “Open” then Excel starts, creates temporary file and then successfully opens the file without any errors.

  3. Anonymous says:

    Thanks for the post, just found this.

  4. Anonymous says:

    To put it in a short way: There is no complete solution for this problem. We should let lose the idea that we will be able to completely get rid of this notification.

    I will try to explain why.

    If you take a look into this blog, you will see that we have a lot of possible causes and in the author provides you for all of the causes a solution or workaround.

    But since the file can be locked by so many different processes, we will never be able to solve the locking issue a 100%.

    For example, if you disable the antivirus software and it seems that this solves you issue, doesn’t mean, that a certain moment the error message (or is it a notification?) will appear again. Simply, because your file is locked by another process.

    What we are trying to achieve by following the action plan in the blog is to minimize the possibility of getting this notification “File is locked”.

    Why do we get the message in the first place?

    Whenever you are opening an Excel file, Windows will grant a handle for the file to the Excel.exe. While you are working, there a number of processes that are checking the file from time to time. This can be the antivirus software or this can be a synchronization process of the operating system (e.g. backup or offline folder synchronization), which will make sure that all you edited data will be correctly saved, virus checked, or backed up later. These other processes are notified by Windows when there are changes to the file and they then attempt to get a handle to the file themselves. At times when Excel temporarily unlocks the file for a few milliseconds, which can for example happen when the file is being saved, other processes might get a chance to grab the file lock and hold it locked even though Excel tries to get hold of it quickly again, resulting in a sharing violation that is then presented to the user as the described alert, if the sharing violation condition cannot be immediately resolved after a few retries. This can also be caused by the Preview pane in Windows explorer, since the preview in the explorer is actually starting an instance of Excel.exe, which means the file is already opened for generating the preview picture while the full instance of Excel is trying to open the file for editing.

    The only potential solution to this problem would be to stop and somehow prevent other background processes from getting a handle lock on a file if the user is about to open it for editing, but this approach would require fundamental new features in the operating system and at the same time changes in the behavior of the background process applications and services. For the moment being, there is no way to avoid such situations completely, and the suggestions and the action plan in the blog can help to minimize the likelihood of such an unwanted event, but the users also need to be aware that this can still happen from time to time and know how to resolve it by manually retrying the operation.

    I hope that clarifies a bit more the case and sets the expectations a bit better.

  5. Anonymous says:

    Very thorough. Nice !

  6. Naeem says:

    I tried everything mentioned on this article, but the issue still there. I have server 2008 R2 SP1 server and windows 7 client.

  7. stevenkkor says:

    You can also try "Long Path Tool" can simplify and probably end your problems in unlocking, managing and renaming files that appear to have a long filename.

  8. With Wings says:

    Shouldn't we leave OpLocks on for Vista+ Offline Files feature as described here:

    support.microsoft.com/…/296264 (Under 'Summary' > 'Note for Vista')

  9. Luma says:

    We use Novell, so what actually fixed was that we turned of file caching

  10. Tim says:

    Hi I have came across this post in looking for an answer and for me the temp workaround of disabling the preview pane so far works.

    But is there an actual fix for this yet?

  11. Lisa says:

    How do I unlock the read only in Excel on the Microsoft Office for Mac 2011?

  12. Anonymous says:

    Pingback from Opening Office files slow over network

  13. Marc says:

    An actual fix would be to identify the user that has the file locked so the second user can inquire if the file is needed any longer or left opened on the taskbar !!!!

  14. Marc says:

    An actual fix would be to identify the user that has the file locked so the second user can inquire if the file is needed any longer or left opened on the taskbar !!!!

  15. Jeroen Rutgers says:

    Problem description:

    Customer is having issues with xlsx files located on a network share.The problem occurs any time customer double-clicks a XLSX file located on the network and Excel is already open We get the “File in Use” error: “ is locked for editing by ‘another user’. Open ‘Read-Only’ or click ‘Notify’ to open read-only and receive notification when the document is no longer in use.
    If we click on “Notify” when we get the error message within 10 seconds it says it is available and we click “Read-Write” and it works
    If we Right-Click on the file and select “OPEN” it works

    To fix the problems customer found the following solution:
    Turn off the Details Pane shown at the bottom of Windows Explorer. Go to Organize -> Layout -> Details Pane
    Win7-Office 2010

    Assesment:

    Whenever you are opening an Excel file, Windows will grant a handle for the file to the Excel.exe.While you are working, there a number of processes that are checking the file from time to time. This can be the antivirus software or this can be a synchronization process of the operating system (e.g. backup or offline folder synchronization), which will make sure that all you edited data will be correctly saved, virus checked, or backed up later. These other processes are notified by Windows when there are changes to the file and they then attempt to get a handle to the file themselves. At times when Excel temporarily unlocks the file for a few milliseconds, which can for example happen when the file is being saved, other processes might get a chance to grab the file lock and hold it locked even though Excel tries to get hold of it quickly again, resulting in a sharing violation that is then presented to the user as the described alert, if the sharing violation condition cannot be immediately resolved after a few retries. This can also be caused by the Preview pane-Details pane in Windows explorer, since the preview in the explorer is actually starting an instance of Excel.exe, which means the file is already opened for generating the preview picture while the full instance of Excel is trying to open the file for editing.

    The only potential solution to this problem would be to stop and somehow prevent other background processes from getting a handle lock on a file if the user is about to open it for editing, but this approach would require fundamental new features in the operating system and at the same time changes in the behavior of the background process applications and services. For the moment being, there is no way to avoid such situations completely, and the suggestions and the action plan in the blog can help to minimize the likelihood of such an unwanted event, but the users also need to be aware that this can still happen from time to time and know how to resolve it by manually retrying the operation.

  16. Anonymous says:

    Pingback from Excel Macro File Locked for editing | Jamleck

  17. Dave M says:

    I’m reposting something from Experts Exchange. In my case, the issue of another user having a file open was isolated to DOC files (not DOCX files). I UNchecked Word 95 (unlike the post below) which worked in my case. Might I be vulnerable to macro viruses?
    Perhaps . . .

    This has to do with the new Trust Settings that are in Office 2010. From the File menu, select Options and then select Trust Center. Then select the File Block Settings. Make sure you have most of the checkboxes cleared. I have only Word 95, 6.0 and Word 2
    and earlier set for Open. All the rest of the documents I leave alone. I also have the Open behavior set for Open selected file types in Protected View.

    These file types can have macro virus’ in them that perhaps the macro checker would not find since they use Word Basic rather than the newer macro controls.

  18. TC says:

    I have got to thank you so much! We were about to junk this computer, and now it is working beautifully. Number III, preview panes, was the problem. Apparently Vista thinks that the preview pane is an "unknown user" locking its use? But you are a lifesaver.

  19. MikeT says:

    I have the exact problem: "An example of this would be if a user had the file open from a server and the server was then rebooted. This causes the connection between the Excel application and the owner file to be broken. When the user then closes the file,
    Excel does not see the need to remove the owner file from the directory, and this results in the orphaned file. When another user later tries to open the same file from that same directory with the orphaned (~filename.xlsx) file, Excel refers to the existing
    owner file for the information to present to the user in the file locked dialog, resulting in the incorrect user information being presented. To resolve this issue, you need only to delete the orphaned ~filename.xlsx file from the directory."

    However, I can’t find where the orphaned ~filename.xlsx in the directory.

    We share couple of Excel worksheets in the office. The are reside on shared folder on the server.

    Please kindly show where on the server can the ophan files be?

  20. Please help me says:

    In our company we have the same error with some Excel files / Users.
    For Example:
    There is one file uses by 20-25 Users.
    Since 2 Weeks they could not see who is locking the file, it only shows "another User".

    I found out that the lock/owner file has 0KB and no User information in it. That must be the problem.
    When I’m opening the Excel list, there is also a Lock file created, but with 1KB and my User Information.

    Then our Users see the message "Locked by “My Username”"
    But this problem is not exist with each excel list.
    That’s really very strange. Does someone have any ideas? (Windows 7 32Bit Office 2010)

  21. slipman says:

    I’m having the same problem. Applied all updates, turned off details and preview pane. Removed hidden file. Still locked and read only. I’m not too crazy about editing the registry or some of the other labor-intensive possible solutions listed. I’m going
    to have to try OpenOffice.

  22. Andrew Evans says:

    One of the reasons we have found you get this error is if the Document has been marked as Final.

  23. File Sharing Settings says:

    We started experiencing this problem after enabling the following registry settings on our file server:

    HKEY_LOCAL_MACHINESystemCurrentControlSetServicesLanmanServerParameters

    EnableOpLocks = 0
    CachedOpenLimit = 0
    EnableOpLockForceClose = 1

    SharingViolationDelay = 0
    SharingViolationRetries = 0

    Autodisconnect = 4294967295 (0xffffffff)

    Also disabling the Details pane seemed to fix it on the client level.

  24. Salesforce Training says:

    Really great post, Thank you for sharing This knowledge.Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up!
    http://predictablepipeline.co.uk/cantgetenoughb2bleads/

  25. reseller gold and silver says:

    I totally appreciated each and every little tad bit of it. I’ve bookmarked your web website to take a gander at out the new stuff you post.
    http://gold-and-silver-buyers.com/how-to-invest-in-gold-and-silver/

  26. uali20 says:

    Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative.
    http://www.ddog.net">shock collar to stop barking

  27. Autolackierung NRW says:

    What a really awesome post this is. Truly, one of the best posts I’ve ever witnessed to see in my whole life. Wow, just keep it up.
    http://car-med.de/smart-lackier-karosserie.html

  28. domains says:

    You have a good point here!I totally agree with what you have said!!Thanks for sharing your views…hope more people will read this article!!!
    http://findyourdomainnow.com

  29. loading help says:

    I actually thought youd have something interesting to say. All I hear is a bunch of whining about something that you could fix if you werent too busy looking for attention.
    http://www.floorsandchores.net

  30. followfy says:

    You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming.
    http://followfy.com

  31. Drip Followers says:

    I recently found many useful information in your website especially this blog page. Among the lots of comments on your articles. Thanks for sharing.
    http://dripfollowers.com

  32. mobile phone tracker says:

    I must say that I do believe this is the best content article. It offers every thing. I used this information to prove to my teacher that I was right and he was wrong. Thanks a lot for proving that!
    http://highstermobilereview.com

  33. tone thighs says:

    Great post. I am the regular targeted visitor of your site and also enjoy you making the effort to help keep your excellent site.
    http://howtolose-thighfat.org

  34. have a peek at this web-site says:

    Thanks for sharing the info, keep up the good work going…. I really enjoyed exploring your site. good resource…
    http://hotpapermoney.com

  35. New York breast implants says:

    This is very educational content and written well for a change. It’s nice to see that some people still understand how to write a quality post!
    http://drracanelli.com

  36. Ricky says:

    So weird, Step III. "Turn off the Preview Pane, Details Pane and pop ups that show information about file and desktop items" actually did it for me.

    Thanks Will!

  37. Sean says:

    The long and short of this is Windows underlying architecture is crap and within MS the left hand has no idea what the right foot is up to. This is the way with so much of their software. Always has been and probably always will be.
    Having Explorer display previews and thumbnails has never been implemented very well (like a lot of things) and even though the features are helpful they are also very unhelpful.