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.