Schedule task when USB device (Keyboard) is unplugged and plugged in

خرید بک لینک

So I would like to schedule a task to run a specific command when a certain hardware (usb) device is unplugged, then another command when it is plugged in.

The commands:

#Unplug
nircmd monitor off
#Plug in
nircmd monitor on

I want this to use as little resources as possible (to keep scripting to a minimum, e.g. I'd like to avoid setting up a constantly running background script, task scheduler by itself should be able to do this job), I'd also like to avoid installing 3rd party software if it can be avoided.

Just about all the information I was able to gather is that there is a logfile C:Windowsinfsetupapi.dev.log which logs all "Device install messages" (Plugged in) but it does not seem to track unplugs.

According to this file the device ID in question is USBVID_1B1C&PID_1B11 (can confirm that on linux the device ID is also 1B1C:1B11, that's how I knew which device I was looking for in the first place, god bless lsusb right?)

This gives me that in task scheduler I should probably be able to set up a "plug-in" task based around the setup api, but since I'm actually not familiar with the task scheduler I don't know how (and more specifically, don't know what "Event ID" I would use)

Where will I find device disconnect events? And how do I make task viewer execute my desired commands for each event?

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 200 تاريخ: شنبه 29 خرداد 1395 ساعت: 23:15

صفحه بندی