From 3a3ba3debbeda821575b1b88c329cd3297219ec9 Mon Sep 17 00:00:00 2001 From: serr Date: Thu, 28 Nov 2024 23:00:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=BF=D0=BA=D0=B0=20=D0=BD=D0=B0?= =?UTF-8?q?=20vbs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2 ЛАБА/допка_на_vbs.vbs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 5 СЕМ/БСИТ/2 ЛАБА/допка_на_vbs.vbs diff --git a/5 СЕМ/БСИТ/2 ЛАБА/допка_на_vbs.vbs b/5 СЕМ/БСИТ/2 ЛАБА/допка_на_vbs.vbs new file mode 100644 index 0000000..d41105b --- /dev/null +++ b/5 СЕМ/БСИТ/2 ЛАБА/допка_на_vbs.vbs @@ -0,0 +1,54 @@ +intInterval = "2" +strDrive = "C:" +strFolder = "\\tools\\" +strComputer = "." + +Set objWMIService = GetObject( "winmgmts:" &_ + "{impersonationLevel=impersonate}!\\" &_ + strComputer & "\root\cimv2" ) + +strQuery = _ + "Select * From __InstanceOperationEvent" _ + & " Within " & intInterval _ + & " Where Targetinstance Isa 'CIM_DataFile'" _ + & " And TargetInstance.Drive='" & strDrive & "'"_ + & " And TargetInstance.Path='" & strFolder & "'" + +Set colEvents = _ + objWMIService. ExecNotificationQuery (strQuery) + +Do + + Set objEvent = colEvents.NextEvent() + Set objTargetInst = objEvent.TargetInstance + + Select Case objEvent.Path_.Class + + Case "__InstanceCreationEvent" + WScript.Echo "Created: " & objTargetInst.Name + + Case "__InstanceDeletionEvent" + WScript.Echo "Deleted: " & objTargetInst.Name + + Case "__InstanceModificationEvent" + + Set objPrevInst = objEvent.PreviousInstance + + For Each objProperty In objTargetInst.Properties_ + If objProperty.Value <> _ + objPrevInst.Properties_(objProperty.Name) Then + WScript.Echo "Changed: " _ + & objTargetInst.Name + WScript.Echo "Property: " _ + & objProperty.Name + WScript.Echo "Previous value: " _ + & objPrevInst.Properties_(objProperty.Name) + WScript.Echo "New value: " _ + & objProperty.Value + WScript.Echo + End If + Next + + End Select + +Loop