Avatar of caymansupport
 asked on

File In Use - Locked For Editing

We have a Word file residing on a Windows 2008 R2 Standard server that is used by many people in our company.  Every night, one designated person needs to be able to update this file.  Frequently, they try to update it and someone has the file still open on their computer, so the updating person gets the message "File is in use.  XYZ.doc is Locked for Editing by "Smith, John". The person who is trying to update the file does not have administrative access to the Server in order to clear the lock.  I am looking for a way - possibly through a batch file or otherwise - that I can give the updating person the ability to clear the locked file so that they are able to edit it.  By the way, the file ALWAYS reads that it is locked by "Smith, John" no matter which user has it open, making it impossible to find the offending computer.  I prefer that the updating person is able to clear it anyway without having to find a computer and log it off.  Any ideas would be appreciated!
Windows NetworkingMicrosoft Word

Avatar of undefined
Last Comment

8/22/2022 - Mon
Kyle Abrahams


net file will get you the list of files.

net file <id> /close will close the file for you.

This would need to be run on the server itself.  I guess you could use PsExec to get around that.

If it's the same file you could use some kind of loop or filter (find?) to get the filename in question, and then if it exists close it.

Hope that helps.
Emmanuel Adebayo

I use TASKKILL command in my case by running saving the file below as batch file and schedule this to run on the server everynight. Obviously I used this to force close all open excel.exe file running every night because one or two users did not close it when leaving office.

TASKKILL /S system /F /IM excel.exe /T

Guilherme Noguchi

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck

No luck so far.  When I try running the Net Files command from the server I get "System Error 5 has occurred.  Access is denied".  Microsoft says it may be related to permissions, but I'm logged into the server with Admin rights.  

I also tried the TASKKILL command on the server from a command prompt.  I'm not sure of the syntax for Word but I tried both of these:
TASKKILL /S system /F /IM word.exe /T
TASKKILL /S system /F /IM winword.exe /T
It took a minute to return an error that said "Error: The RPC Server is unavailable".  But the RPC service running and to my knowledge we're not having any DNS issues.  

Unfortunately SharePoint isn't an option since we're part of a large organization with strict controls.
Kyle Abrahams

did you run the command prompt as administrator?

type cmd into run
right click cmd in the results -> run as administrator.
Guilherme Noguchi

openfiles.exe /disconnect /s server2008 /op "c:\my documents\somedoc.doc"

Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.

None of the above worked for me.  I ended up installing an app called "Unlocker" on the server and removing it through that.  Then I converted the doc file to docx and when we point to it now it opens properly. Thanks everyone for your help.

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.

It works.  I would say it was an "A" solution but it isn't ideal since it does involve a network disconnection which may affect other things.  It also is scheduled, so the file can't be unlocked at any time the person wants to unlock it (which is a disadvantage).