2

i'm using Windows' task scheluder to trigger a task when a specific USB device is plugged to the computer, problem is the task is also triggered on USB removal.

I used custom XML trigger for this task tracking Windows auditing logs for a specific reg key read on

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\USBSTOR\

that happens on USB insert, and unfortunately on USB removal too.

When comparing differences between insert and removal events, only differences were "TimeCreated SystemTime" "EventRecordID" and "HandleId" but i can't rely on those as they will never be the same.

I would like to know if there's a better solution that will make use of Windows' task scheduler, preferably without any additional background service but as we are on a open minded platform if you have an idea that involve background service, please share it too, it may be useful to future serverfault users crawling for a solution.

Zulgrib
  • 351
  • 5
  • 19
  • Does the USB device acquire a drive letter? Could you add a test to your task so it checks if the device exists before running? So on insert > trigger > check device exists > run. And on removal > trigger > check for device > no device > not run – BlueCompute Jun 11 '14 at 12:32
  • Yes the device acquire a drive letter, but i don't know how to check if drive exist at trigger level, I only know how to do this at action level and action level is too late. If you can guide me on how to check that at trigger level, it would be a perfect solution. – Zulgrib Jun 11 '14 at 15:02
  • I was suggesting to run a sub-task / action that runs the test and then invokes or doesn't the main task. I don't know how to check at trigger level. – BlueCompute Jun 11 '14 at 15:25

0 Answers0