Skip to content

Instantly share code, notes, and snippets.

@vensko
Created October 31, 2015 15:19
Show Gist options
  • Save vensko/274cd18c92e99b137124 to your computer and use it in GitHub Desktop.
Save vensko/274cd18c92e99b137124 to your computer and use it in GitHub Desktop.
<?php
$wmi = new COM("winmgmts:{impersonationLevel=impersonate}!//./root/cimv2");
$events = $wmi->ExecNotificationQuery("Select * From __InstanceOperationEvent Within 2 Where (Targetinstance Isa 'CIM_DataFile' Or Targetinstance Isa 'CIM_Directory') And TargetInstance.Drive='e:' And TargetInstance.Path='\\\\WATCH_DIRECTORY\\\\'");
while ($latestEvent = $events->NextEvent()) {
print_r($latestEvent->Path_->Class);
print_r([
$latestEvent->TargetInstance->Name,
$latestEvent->TargetInstance->Drive,
$latestEvent->TargetInstance->Path,
$latestEvent->TargetInstance->Extension,
$latestEvent->TargetInstance->FileSize,
$latestEvent->TargetInstance->Writeable,
]);
echo "\n\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment