
Auf meiner Festplatte laufen verschiedene Dinge. Ich möchte ungefähr feststellen, wie viel Festplattenaktivität auf die gemeinsame Nutzung von Dateien zurückzuführen ist. Gibt es dafür einen Zähler?
Außerdem glaube ich mich, ein Programm gesehen zu haben, mit dem ich die Dateiaktivität eines bestimmten Ordners innerhalb einer Freigabe überwachen kann (vielleicht habe ich das auch geträumt). Sagt Ihnen das etwas? Danke.
Antwort1
In Bezug auf die Überwachung der Aktivität eines Ordners:
Sie können WMI (CIM_DataFile) verwenden, um einen Ordner auf Änderungen zu überwachen. Als Abfrage können Sie Folgendes verwenden:
SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE TargetInstance ISA "CIM_DataFile" AND TargetInstance.Drive="C:" AND TargetInstance.Path="\Data"
Etwas wie das:
' Full path to the folder to monitor
sPath = "\\localhost\c$\Scripts"
sComputer = split(sPath,"\")(2)
sDrive = split(sPath,"\")(3)
sDrive = REPLACE(sDrive, "$", ":")
sFolders = split(sPath,"$")(1)
sFolders = REPLACE(sFolders, "\", "\\") & "\\"
' Create our WMI instance
Set objWMIService = GetObject("winmgmts:\\" & sComputer & "\root\cimv2")
' Begin monitoring
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 1 WHERE " _
& "TargetInstance ISA 'CIM_DataFile' AND " _
& "TargetInstance.Drive='" & sDrive & "' AND " _
& "TargetInstance.Path='" & sFolders & "'")
Wscript.Echo vbCrlf & Now & vbTab & _
"Begin Monitoring for a Folder Change Event..." & vbCrlf
Do
Set objLatestEvent = colMonitoredEvents.NextEvent
Select Case objLatestEvent.Path_.Class
Case "__InstanceCreationEvent"
WScript.Echo Now & vbTab & objLatestEvent.TargetInstance.FileName _
& " was created" & vbCrlf
Case "__InstanceDeletionEvent"
WScript.Echo Now & vbTab & objLatestEvent.TargetInstance.FileName _
& " was deleted" & vbCrlf
Case "__InstanceOperationEvent"
If objLatestEvent.TargetInstance.LastModified <> _
objLatestEvent.PreviousInstance.LastModified then
WScript.Echo Now & vbTab & objLatestEvent.TargetInstance.FileName _
& " was modified" & vbCrlf
End If
IF objLatestEvent.TargetInstance.LastAccessed <> _
objLatestEvent.PreviousInstance.LastAccessed then
WScript.Echo Now & vbTab & objLatestEvent.TargetInstance.FileName _
& " was accessed" & vbCrlf
End If
End Select
Loop
Set objWMIService = nothing
Set colMonitoredEvents = nothing
Set objLatestEvent = nothing