Answer» Hi experts,
Files with different datas are kept in a common subdirectory.
Would like to KNOW how many times a particular file have been open and by dates. This information need to be saved in a log (text) file in another separate (not common) directory.
(The intention is to know which files is the most POPULAR. Using XP) As a newbie, which scripting language is the best and which web site provides samples?
Thanks.
It's easy enough to WRITE a script that will monitor events resulting in a change to the file system. Opening a file for input (reading) does NOT produce an event that can be monitored. With a little imagination, you could log the events to a file and create a script to summarize the activity. (EXCEL?, perhaps)
This script will monitor file system events in the c:\windows\system32 directory:
Code: [Select]strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _ ("SELECT * FROM __InstanceOperationEvent WITHIN 3 WHERE " _ & "Targetinstance ISA 'CIM_Datafile' and " _ & "TargetInstance.Drive = 'c:' And "_ & "TargetInstance.Path= '\\windows\system32\\'") Do Set objLatestEvent = colMonitoredEvents.NextEvent() 'WScript.Echo objLatestEvent.Path_.Class & " " & objLatestEvent.TargetInstance.Name
Select Case objLatestEvent.Path_.Class Case "__InstanceCreationEvent" WScript.Echo "File Created: " & objLatestEvent.TargetInstance.Name Case "__InstanceDeletionEvent" WScript.Echo "File Deleted: " & objLatestEvent.TargetInstance.Name Case "__InstanceModificationEvent" WScript.Echo "File Modified: " & objLatestEvent.TargetInstance.Name End Select Loop
There are many free scripting languages. Choosing one is like wine. Choose the one you like. VBScript and JScript are installed free with every Windows version except Win95 (A & B). They're easy to use and understand.
Perl, Python and PHP are popular but are geared to the internet. Can be run within Windows.
REXX comes from IBM mainframes (VM/CMS). Both versions (Classic & Object) have been ported to Windows. (note: the REXX IDE is proprietary ($$$) but the interpreter is free).
The nice thing about script is they are not compiled and linked. Running under an interpreter, all you need is an editor (notepad works fine) to create a text file.
A good script site with plenty of VBScript examples is the Script Center
Good luck. 8-)
|