Open "Locked"? file from network in 2 steps

Open "Locked" file from network in 2 steps

Ever wanted to open a file on a network, only to get the awful "locked for editing by another user" message? Well, here is a small trick I use.

No alt text provided for this image

Why?

In my workplace, we have a weekly meeting on Monday morning to discuss the individual tasks for the week. This basically means, every person in our team tries to open up the same excel file to fill out during the 30 min interval before the meeting. Needless to say, it's a disaster.

That's why I came up with this idea - This script waits until the current user has exited the file and opens it up before anyone else can get into it.

Here's how you can do the same.

  1. Open up the notepad and copy paste the below code:
@echo off

set file="ENTER_FILE_PATH_HERE"
goto check

:wait
echo.
echo File locked - Trying again.
TIMEOUT /T 10
goto check

:check
2>nul (
  >>%file% echo off
) && (%file%) || (goto wait)
  • Be sure to replace ENTER_FILE_PATH_HERE with the full path to your file (Example: C:\Users\Arun\Desktop\Temp\Book 2.xls)

2. Save the notepad with ".bat" file extension and the Save as type option is set to All Files (*.*)

No alt text provided for this image

That's it! Simply double click on the file to open up the document.

How this works

When you open the bat file - It check to see if the specified file is locked by any user. If it is - It simply waits for 10 seconds and retries again.

As soon as the file is unlocked - It opens it up for you.

Tada! Magic at your finger tips :D

要查看或添加评论,请登录

社区洞察

其他会员也浏览了