JustScriptIt
Technical User
Hello,
I am following along
Managing Windows® with VBScript and WMI
Don Jones
Addison-Wesley Professional
English, 2004, 640 pages
ISBN/ISSN: 0-321-21334-3
And am using their script
However, when I try it on my own computer, and choose a file that I opened, I always get the output
"Didn't find that file opened by anyone"
The file exists and I opened it.
What gives?
I am following along
Managing Windows® with VBScript and WMI
Don Jones
Addison-Wesley Professional
English, 2004, 640 pages
ISBN/ISSN: 0-321-21334-3
And am using their script
Code:
Option Explicit
Dim varServer, varFile, objFS, varFoundNone, objRes
' first, get the server name [not IP address] we want to work with
varServer = InputBox ("Server name to check")
' get the local path of the file to check. Must start with drive letter, and cannot be UNC
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. Uses Active Directory Services Interface (ADSI) to connect to
' 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, display a msg
if varFoundNone = True then
WScript.Echo "Didn't find that file opened by anyone."
end if
However, when I try it on my own computer, and choose a file that I opened, I always get the output
"Didn't find that file opened by anyone"
The file exists and I opened it.
What gives?