Solving half the problem !
I have transformed the VB code that masken found to KiX.
This will tell the user who has locks on the file, they can then phone the offending users, and ask them to close the file.
I have not tested the script with a domain user account, so it might not work, but used with admin rights it is very quick.
(Excel must be installed, because the script uses Excel for output !!)
code:
Dim $oFSO, $Resource
Dim $FileName, $ServerName
Dim $Row, $oXL
'Enter filename or part of filename of locked file: '
GetS $FileName
?'Enter servername: '
GetS $ServerName
? 'Checking locks for filename: ' + $FileName + ' on server: ' $ServerName
$oXL = CreateObject("Excel.Application")
$RC = $oXL.workbooks.add()
$oXL.Cells(1, 1).Value = "User"
$oXL.Cells(1, 2).Value = "Path"
$oFSO = GetObject("WinNT://" + $ServerName + "/LanmanServer")
$Row = 2
If VarTypeName($oFSO) = 'Object'
For Each $Resource In $oFSO.Resources
If $Resource.User <> "" And Right($Resource.User,1) <> "$"
If InStr($Resource.Path, $FileName)
$oXL.Cells($Row, 1).Value = $Resource.User
$oXL.Cells($Row, 2).Value = $Resource.Path
$Row = $Row + 1
EndIf
EndIf
Next
EndIf
$oXL.Cells($Row + 1, 1).Value = 'Filename: ' + $FileName
$oXL.Cells($Row + 1, 2).Value = 'Number of file locks: ' + CStr($Row - 2)
$RC = $oXL.Cells.EntireColumn.Autofit
$oXL.Visible = True
$oXL = 0
-Erik