
Tested on:
Windows NT Server
Windows 2000 Server
Sometimes we are unable to delete a file because it's been locked by another process which may have crashed or otherwise terminated without unlocking the file.
The error messages:
"There has been a sharing violation."
"The source or destination file may be in use."
Are commonly seen in these situations.
The simple solution to this problem is to reboot the server, all file locks are freed and the file can be moved, renamed or deleted without any problems. However, in a live environment, server reboots are not always acceptable. That leaves us with the tiny window on Server Manager that lists all the file locks, not much use.
Here's a way to free that file and leave the server up and running.
First, log on to the server where the file is located. (You'll need admin rights over this machine.)
At the command prompt, type:
NET FILE |
ID Path User name # Locks ----------------------------------------------------------------------------------- 18 F:\Backup\Mailbox.pst ADMINISTRATOR 0 40 C:\WINNT\Profiles\All Users ADMINISTRATOR 0 85 E:\Userdata\RES_CLERK_1\Templates\Memo.dot RES_CLERK_1 1 89 E:\Userdata\RES_CLERK_1\Mailbox.pst RES_CLERK_1 1 |
NET FILE > InUse.txt |
NET FILE (FileIDNumber)
|
NET FILE (FileIDNumber) /CLOSE
|
Note: This should only be used against files locked on servers by network clients.
Problems, ideas, better routines ?
Mail me or drop into the forums