If you’re ever locked out of your computer, there are a few things you can do to help get back in. One is to try to find the file that’s been locked, and replace it if necessary. Another option is to use a software program to unlock your computer from the inside.

Track down and contact the users who are currently using the file, tell them to close out/save their work, etc. and then apply the update. Don’t apply the update immediately and just remember to do it later when users are not in the system. Schedule some utility to replace it at the next reboot.

Well, we have another solution available for you: a script you invoke via the Send To menu which does the following:

Tries to delete the old file. If the old file is locked, the script waits 20 seconds. Go to step 1. If the old file is not locked, the old file is replaced with the new file. Go to step 4. Optionally log off once the process is done.

This way, you get just get the replace command in motion and the script takes care of the rest. This can help you avoid tracking down users or having to install unnecessary utilities on your system.

Setup and Usage

The script can be placed anywhere on your system. Then all you need to do is create a shortcut to it in your SendTo folder:

To start the replace process, select the old file and new file and then invoke the Send To option by right clicking on the old file/file to replace.

The script will display exactly what will happen and present you with the option to be logged off once the replace is completed.

The script will continuously try to delete the old file while waiting several seconds in between tries.

 

All you have to do is get the process running and whenever all your users are out, the file will be replaced.

Safeguards

The script has a couple of built in safeguards:

The old file and new file are clearly presented so you know exactly what will happen. You can close the command window at any time to stop the action (of course, assuming the replace has not been performed already). The script will ensure you have selected only two files when you invoke the Send To command. If you select, for example, 1 or 3 files you will receive a notice message and nothing will happen.

The Script

Download ReplaceFile Script from SysadminGeek.com