Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Monitor a file, generate log when it was copied

Reply
 
Old 09-25-2009   #1 (permalink)
Buddy


 
 

Monitor a file, generate log when it was copied

To All:

I'm looking for a method to monitor a specify doc, when it was copied it
will generate a log,
the doc file has been encrypted.Any idea?



My System SpecsSystem Spec
Old 09-25-2009   #2 (permalink)
Pegasus [MVP]


 
 

Re: Monitor a file, generate log when it was copied


"Buddy" <qinfengbin@newsgroup> wrote in message
news:uLZ8SWZPKHA.3256@newsgroup
Quote:

> To All:
>
> I'm looking for a method to monitor a specify doc, when it was copied it
> will generate a log,
> the doc file has been encrypted.Any idea?
Can you be a little more specific?


My System SpecsSystem Spec
Old 09-25-2009   #3 (permalink)
Buddy


 
 

Re: Monitor a file, generate log when it was copied

The File's Full Path is d:\documents\List.Doc.If someone copy this file, and
it will generate a log file.

"Pegasus [MVP]" <news@newsgroup> дÈëÏûÏ¢ÐÂÎÅ:eGYX9WbPKHA.4580@newsgroup
Quote:

>
> "Buddy" <qinfengbin@newsgroup> wrote in message
> news:uLZ8SWZPKHA.3256@newsgroup
Quote:

>> To All:
>>
>> I'm looking for a method to monitor a specify doc, when it was copied it
>> will generate a log,
>> the doc file has been encrypted.Any idea?
>
> Can you be a little more specific?
>

My System SpecsSystem Spec
Old 09-25-2009   #4 (permalink)
Pegasus [MVP]


 
 

Re: Monitor a file, generate log when it was copied

OK. What if the file already exists? What if someone edits, then saves the
file?

"Buddy" <qinfengbin@newsgroup> wrote in message
news:uycDuBePKHA.4244@newsgroup
Quote:

> The File's Full Path is d:\documents\List.Doc.If someone copy this file,
> and it will generate a log file.
>
> "Pegasus [MVP]" <news@newsgroup>
> дÈëÏûÏ¢ÐÂÎÅ:eGYX9WbPKHA.4580@newsgroup
Quote:

>>
>> "Buddy" <qinfengbin@newsgroup> wrote in message
>> news:uLZ8SWZPKHA.3256@newsgroup
Quote:

>>> To All:
>>>
>>> I'm looking for a method to monitor a specify doc, when it was copied it
>>> will generate a log,
>>> the doc file has been encrypted.Any idea?
>>
>> Can you be a little more specific?
>>
>
>

My System SpecsSystem Spec
Old 09-25-2009   #5 (permalink)
mr_unreliable


 
 

Re: Monitor a file, generate log when it was copied

Buddy wrote:
Quote:

> I'm looking for a method to monitor a specify doc, when it was copied it
> will generate a log, the doc file has been encrypted.Any idea?
>
hi Buddy,

I will be greatly surprised if you find a way to do this
via script.

Generally speaking, when you wish to be notified of some
system activity, you have to insert a "hook" into the
system. In your case, an appropriate hook would be
a "Copy Hook". Read this:

http://msdn.microsoft.com/en-us/libr...63(VS.85).aspx

As you can see, that is a somewhat sophisticated mechanism,
and requires some other language (not vbs).

I had initially thought that one of the "File Watcher"
utilities might be of use, but after reading through some
of the descriptions of these utilities, I think not.
But then, you can google "File Watcher Utility" and
see for yourself.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)
My System SpecsSystem Spec
Old 09-26-2009   #6 (permalink)
Buddy


 
 

Re: Monitor a file, generate log when it was copied

To All:
Thanks For All Your Help, I also think it's very difficult.So if there's
a tool to do job is also OK!

"mr_unreliable" <kindlyReplyToNewsgroup@newsgroup>
??????:ODunV7fPKHA.352@newsgroup
Quote:

> Buddy wrote:
Quote:

>> I'm looking for a method to monitor a specify doc, when it was copied it
>> will generate a log, the doc file has been encrypted.Any idea?
>
> hi Buddy,
>
> I will be greatly surprised if you find a way to do this
> via script.
>
> Generally speaking, when you wish to be notified of some
> system activity, you have to insert a "hook" into the
> system. In your case, an appropriate hook would be
> a "Copy Hook". Read this:
>
> http://msdn.microsoft.com/en-us/libr...63(VS.85).aspx
>
> As you can see, that is a somewhat sophisticated mechanism,
> and requires some other language (not vbs).
>
> I had initially thought that one of the "File Watcher"
> utilities might be of use, but after reading through some
> of the descriptions of these utilities, I think not.
> But then, you can google "File Watcher Utility" and
> see for yourself.
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
> the answers will be applicable to the questions)

My System SpecsSystem Spec
Old 09-26-2009   #7 (permalink)
Buddy


 
 

Re: Monitor a file, generate log when it was copied

To Pegasus :
It ignore the other event but copy event.

"Pegasus [MVP]" <news@newsgroup> дÈëÏûÏ¢ÐÂÎÅ:eI7OfDfPKHA.4428@newsgroup
Quote:

> OK. What if the file already exists? What if someone edits, then saves the
> file?
>
> "Buddy" <qinfengbin@newsgroup> wrote in message
> news:uycDuBePKHA.4244@newsgroup
Quote:

>> The File's Full Path is d:\documents\List.Doc.If someone copy this file,
>> and it will generate a log file.
>>
>> "Pegasus [MVP]" <news@newsgroup> дÈëÏûÏ¢ÐÂÎÅ:eGYX9WbPKHA.4580@newsgroup
Quote:

>>>
>>> "Buddy" <qinfengbin@newsgroup> wrote in message
>>> news:uLZ8SWZPKHA.3256@newsgroup
>>>> To All:
>>>>
>>>> I'm looking for a method to monitor a specify doc, when it was copied
>>>> it will generate a log,
>>>> the doc file has been encrypted.Any idea?
>>>
>>> Can you be a little more specific?
>>>
>>
>>
>
>

My System SpecsSystem Spec
Old 09-26-2009   #8 (permalink)
Pegasus [MVP]


 
 

Re: Monitor a file, generate log when it was copied


"Buddy" <qinfengbin@newsgroup> wrote in message
news:ueX6jGpPKHA.1280@newsgroup
Quote:

> To Pegasus :
> It ignore the other event but copy event.
Here you go. The script is based on an idea by the Scripting Guy.

sFileName = "d:\temp\test.txt"
iInterval = 60000 'Milliseconds

sName = "'" & Replace(sFileName, "\", "\\") & "'"
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_Datafile Where Name = " & sName)

For Each objFile In colFiles
strOriginalTimestamp = objFile.LastModified
Next

WScript.Echo "Monitoring """ & sFileName & """ " & Now

Do While True
WScript.Sleep iInterval
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_Datafile Where Name = " & sName)

For Each objFile In colFiles
strLatestTimestamp = objFile.LastModified
Next

If strLatestTimestamp <> strOriginalTimestamp Then
strOriginalTimestamp = strLatestTimestamp
WScript.Echo Now & " The file """ & sFileName _
& """ has been modified in the last " _
& iInterval\1000 & " seconds"
strOriginalTimestamp = strLatestTimestamp
End If
Loop


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Does Vista Generate a file during the update process? Vista General
RE: Can we generate a VHD file out of a real Hard Disk? Virtual PC
new name of copied file VB Script
file has properties that cannot be copied Vista General
File Manager doesn't display WHAT file is being copied/moved!?!?!?! Vista file management


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46