View Single Post
  #16  
Old September 6th 20, 01:16 AM posted to alt.comp.os.windows-10,alt.msdos.batch,alt.comp.microsoft.windows
Arlen Holder
external usenet poster
 
Posts: 186
Default What solution do you use to figure out what USB drive letter in a Windows scripted command?

On Sat, 5 Sep 2020 13:20:58 -0400, Big Al wrote:

Just hope you don't have ?:\software on two drives.


We have to choose _something_ to identify the drive.

I would have loved to identify the volume label, or, better yet, the device
serial number, but I didn't find any examples on the net that were even
close.

For finding the serial number, Poutnik proposed a Nirsoft utility, which
not only easily reports the serial number, but also (if you're an admin),
allows simply right-click change of the drive letter.
https://www.nirsoft.net/utils/usb_devices_view.html
https://www.nirsoft.net/utils/usbdeview-x64.zip
Name: USBDeview.exe
Size: 189816 bytes (185 KiB)
SHA256: 0C93E5C815BA258750CE4762A4CDB8FA746B05D525BD463ED6 DBE243CD790FB2

Running USBDeview and comparing to the Microsoft and the Sieber usbview,
this Nirsoft utility is the same but different in a whole bunch of ways.

It presents the USB data in a columnar fashion, one row per USB device,
where my USB stick in question showed up as a named drive letter, a given
serial number, etc.

In summary, we have to key off of "something" to identify the drive:
a. The serial number of the USB device
b. The volume name of the USB device
c. The label of the USB device
d. The mount point (aka Drive Letter) of the USB device
e. A filespec on the USB device
etc.

Of all these things, I prefer the "serial number" as we can presume that's
"most" unique (for some value of uniqueness); but I don't even know how to
programmatically obtain the serial number of a mounted USB volume.
https://hatsoffsecurity.com/2014/06/05/usb-forensics-pt-1-serial-number/

Googling, I see these commands report serial numbers of all drives
but strangely enough, they each report a _different_ serial number
for the same USB device!
o Win+R %comspec% /k vol j:
o Win+R %comspec% /k wmic diskdrive get Model, Name, InterfaceType, SerialNumber

In summary, one solution to avoid the problem you speak of where
two USB drives may have the same filespec, is to modify the
script to identify the USB stick by it's "unique" serial number
--
Usenet allows purposefully helpful people to suggest & share ideas.
Ads