usbdrivedetector icon indicating copy to clipboard operation
usbdrivedetector copied to clipboard

Is there any way to retreive Vendor ID and Product Id from removable devices?

Open sushiljic opened this issue 5 years ago • 6 comments

I need to use verify the pendrive by its vendor ID and Product ID for its uniqueness so is there way to get VID and PID?

sushiljic avatar Jan 27 '20 15:01 sushiljic

Not with this library, but on linux you could execute 'lsusb' and see if the VID:PID is listed (the device and/or mount point will not be listed so there's no way to link anything if there are multiple identical pendrives attached.

MarkJeronimus avatar Mar 18 '20 09:03 MarkJeronimus

Do you need to identify the pendrive using the VID and PID specifically? Can't you use the Serial Number instead?

samuelcampos avatar Apr 04 '20 00:04 samuelcampos

@samuelcampos I need vendor ID and product ID because It can't be changed easily whereas Serial Number can be changed and also It get changed when formatted. It is good library and It would be best if we can retrieve VID and PID too.

sushiljic avatar Aug 27 '20 15:08 sushiljic

@samuelcampos I need vendor ID and product ID because It can't be changed easily whereas Serial Number can be changed and also It get changed when formatted. It is good library and It would be best if we can retrieve VID and PID too.

Indeed. When expecting a specific device, one could make sure to find the mount point of that particular device. Library looks great anyway! :-)

marian-m12l avatar Sep 04 '20 20:09 marian-m12l

If you already know what USB device that is used one way that is supported is to give the USB device a Volume Name and inside the code check for device.getDeviceName().equalsIgnoreCase("myVolumeName"). Also the mount point might not be that important since the device has a method which returns the root directory as a file. That would be device.getRootDirectory().

Avec112 avatar Mar 01 '23 06:03 Avec112

maybe it can help you (only jdk21 with preview):

  • https://github.com/manuelbl/JavaDoesUSB

ouaibsky avatar Oct 11 '23 20:10 ouaibsky