D
D
disik2017-05-15 20:00:04
USB
disik, 2017-05-15 20:00:04

How to get an event in the event log about connecting a USB device?

Hello,
how do I get an event in the event log about connecting a USB device? Not mass storage, it's written about it everywhere, but any device? Yes, with the ability to filter by VID / PID? Only necessarily by means of Windows itself.
I feel that somehow it is possible, but so far I have not found such a method.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
1
15432, 2017-05-15
@15432

Periodically call all sorts of SetupDi and check what appeared in the list ...
Approximately described here
stackoverflow.com/questions/7599331/list-usb-devic...

E
Ezhyg, 2017-05-18
@Ezhyg

It won’t work for everyone at once, there are different event codes for different devices and all that.
try filtering by:
ServiceName - UserPnp, event codes: 20003 (MTP device being installed), 20001 (camera being installed)
or DeviceInstanceID - USB

A
Alex, 2017-05-19
@asilonos

Can be done in PowerShell using WMI or WMI Events.
( https://technet.microsoft.com/en-us/library/ff7309...
and using WMIExplorer you can experiment with requests like:
- select * from CIM_USBDevice
And register its execution in the Service or in Autorun, but here you need to experiment Can
you find out what problem or task you want to solve with this?
What if you install PC monitoring software that also monitors all connected devices ... or maybe block it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question