' get the name of the server to check varServer = InputBox ("Server name to check") ' Get the local path of the file to check varFile = InputBox _ ("Full path and filename of the file on the" & _ "Server (use the local path as if you were at the" & _ "Server console)") ' bind to the server's file service set objFS = GetObject("WinNT://" & varServer & "/lanmanserver,fileservice") ' scan through the open resources until we ' locate the file we want varFoundNone = True ' use a For...Each loop to walk through the ' open resources For Each objRes in objFS.resources ' does this resource match the one we're looking for? if objRes.path = varFile then 'We found the file -show who's got it varFoundNone = False WScript.Echo objRes.Path & " is opened by" & objRes.User End If Next ' if we didn't find the file open, then display a MSG if varFoundNone = True then WScript.Echo "Didn't find that file open by anyone." End If
Edited by groovicus, 05 September 2010 - 10:30 AM.
added code tags