Re: how to tell if a file is being accessed




"parminder" <parminder@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C49CE739-CF43-48E6-9A09-29BFD1FB64D2@xxxxxxxxxxxxxxxx
Hello,

I am trying to figure out how one can tell if a file is being accessed. I
am
not worried about the kind of application accessing the file (it can be
anything from word to media player). I only want to know if a file is
being
accessed.
Any pointers will be appreciated.

First, I deduce that you have no interest in knowing who might be accessing
the file.

Which question is it that you want to be able to answer:

a) is this file being accessed right now?
b) has this file been accessed since some time in the past, say, the last
time I checked?

in scenario "a", it is possible to determine if a file is currently "open".
Forgetting scripting for a moment, this can be determined by opening up the
computer management console, and drilling down to system tools \ shared
folders \ open files.

But now it does depend on what application is being used on the file. Word,
for one example, will mark a file as open when you are editing it. In that
state, the file cannot (easily) be deleted. Another common file editor
called Notepad does not do this. Instead, it reads the file contents and
closes the file, updating it (by opening, writing, and closing) only when
specifically directed by the user. You can, in fact, have a file open for
editing in Notepad while another process deletes the file.

scenario "b" is quite different, and might be achieved by examining the
"accessed date" of the file. You could, conceivably, have a script
continually monitoring this attribute, and then notify you when it detects a
change. There might also be a way with WMI to monitor for this happening,
something along the lines of monitoring a folder for new files. Sorry,
though, but I have no experience in such aspects of WMI.


/Al


.



Relevant Pages

  • Re: Creating a Service with Systray icon
    ... monitoring and configuring, I've decided to use the socket client way. ... > For richer two way communication, you can use .NET remoting. ... > You can also use WMI (Windows Management ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Monitoring Service Activity
    ... WMI Event Publishing, right? ... >>a loop forever and ever, ... >> back and forth between the monitoring application. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Problem with SBS monitoring and reporting
    ... But when I send the query i get the error 0x80041010. ... Facility WMI, Discription: Invalid Class. ... I'd like to double check the steps of the SBS monitoring reinstalling ... Set Server Tools to Maintenance. ...
    (microsoft.public.windows.server.sbs)
  • Windows Service Creating a process in Windows 2003 SP1 with WMI
    ... It uses WMI to query whether or not a process is running, and if not, ... The Monitoring application runs as a service on the local machine using ... about a Windows Service starting a Windows application via WMI. ...
    (microsoft.public.win32.programmer.wmi)

Loading