1.

Solve : .bat tracking program!?

Answer» <html><body><p>hello again!!!<br/>just want to monitor the files/folders in our server.<br/>is there a .bat <a href="https://interviewquestions.tuteehub.com/tag/code-25512" style="font-weight:bold;" target="_blank" title="Click to know more about CODE">CODE</a> to track if a file/folder was copied/opened/explored?<br/>or some tips to identify if a file/folder was copied/opened/explored?<br/>any suggestion??? Monitoring  and user notification of file creation, deletion, and <a href="https://interviewquestions.tuteehub.com/tag/modification-770646" style="font-weight:bold;" target="_blank" title="Click to know more about MODIFICATION">MODIFICATION</a> can be scripted with VBScript using the Windows Management Instrumentation (WMI) interface. Batch code simply does not have the functionality for this task.<br/><br/>The events you mentioned (copied/opened/explored) cannot be trapped. I guess Microsoft doesn't deem them worthy of notice.  <br/><br/>If you can use a VBScript, let us know and we'll see what we can <a href="https://interviewquestions.tuteehub.com/tag/whip-1454915" style="font-weight:bold;" target="_blank" title="Click to know more about WHIP">WHIP</a> up.<br/><br/> <br/><br/> Quote from: night-rider on June 25, 2010, 04:25:45 AM</p><blockquote>any suggestion??? <br/></blockquote> <br/>Please avoid using multiple exclamation and question marks.<br/> <br/>sorry!<br/>oic!<br/>then what will be the code then for vbs? Quote from: night-rider link=topic=106393.msg718370#msg718370 [img<blockquote>[/img]date=1277250711]<br/>hello again!!!<br/>just want to monitor the files/folders in our server.<br/>is there a .bat code to track if a file/folder was copied/opened/explored?<br/>or some tips to identify if a file/folder was copied/opened/explored?<br/><br/></blockquote> I am confused with that. Quote from: night-rider on June 26, 2010, 12:07:03 AM<blockquote> <br/>sorry!<br/>oic!<br/>then what will be the code then for vbs? <br/></blockquote> <br/> Code: <a>[Select]</a>strComputer = "."<br/>Set objWMIService = GetObject("winmgmts:\\" &amp; strComputer &amp; "\root\cimv2")<br/><br/>Set colMonitoredEvents = objWMIService.ExecNotificationQuery _<br/>    ("SELECT * FROM __InstanceOperationEvent WITHIN 3 WHERE " _   <br/>        &amp; "Targetinstance ISA 'CIM_Datafile' and " _<br/>            &amp; "TargetInstance.<a href="https://interviewquestions.tuteehub.com/tag/drive-959713" style="font-weight:bold;" target="_blank" title="Click to know more about DRIVE">DRIVE</a> = 'c:' And "_ <br/>      &amp; "TargetInstance.Path= '\\temp\\'")<br/> <br/>Do <br/>    Set objLatestEvent = colMonitoredEvents.NextEvent()<br/>    'WScript.Echo objLatestEvent.Path_.Class &amp; " " &amp; objLatestEvent.TargetInstance.Name<br/><br/>    Select Case objLatestEvent.Path_.Class<br/>      Case "__InstanceCreationEvent"<br/>      WScript.Echo "File Created: " &amp; objLatestEvent.TargetInstance.Name<br/>      Case "__InstanceDeletionEvent"<br/>      WScript.Echo "File Deleted: " &amp; objLatestEvent.TargetInstance.Name<br/>      Case "__InstanceModificationEvent"<br/>      WScript.Echo "File Modified: " &amp; objLatestEvent.TargetInstance.Name<br/>    End Select<br/>Loop<br/><br/>You can change the drive and path as required. Use double backslashes. The WITHIN clause defines the time interval between snapshots. Make it too small and the script will run too often. Make it too big and you may miss some events. For example if you set it to 20 and a file creation event and file deletion event for the same file occurs within the 20 seconds, the script will not notice any change between snapshots and will not report either of the events.<br/><br/>Save the script with a <strong>VBS</strong> extension. Run from the command prompt as <strong>cscript <em>scriptname.vbs</em></strong>. Best to run with <strong>cscript;</strong> <strong>wscrip</strong>t will produce popup windows which can be very annoying. Script <a href="https://interviewquestions.tuteehub.com/tag/runs-246860" style="font-weight:bold;" target="_blank" title="Click to know more about RUNS">RUNS</a> in a loop waiting for events to happen in the directory defined in the script. If using <strong>cscript</strong>, use CTL-C to terminate the script. If using <strong>wscript,</strong> use the task manager to terminate the script.<br/><br/>Good luck.</body></html>


Discussion

No Comment Found