ot: check to see if a specific usb thumb drive is present, at a command line

You may want to see if a certain usb thumb drive is (still, or again) plugged in to
this computer.   Presuming you know what the hardware serial number is
{not the filesystem  UUID  or  windows VOL  e:  command id number, which
are part of a particular filesystem on the media, but the hardware id assigned
at the factory {although googling this I see some claims it can be hacked in the 
field, with some effort};  doing this check from the cmd.exe  or the bash command 
line is not very hard, as it turns out.

If you're running redhat linux,    do this at bash;
  lsusb  -v
    and search the output for lines that have a left margin heading of "iSerial"
hopefully you will find the expected serial number there in one of the
paragraphs.  Drop the whitespace and the single digit line counter like 3 in
  IManufacturer           1
  IProduct                    2
  ISerial                      3  07032A9AFF92284
You might also want to take notice of the  idVendor and idProduct  lines,
        like 0x13fe   and 0x4100  for the sample device I'm holding, as a match
   for them but mismatch for serial number suggests the staff picked up a 'twin'
  for the desired usb thumb drive, by mistake.  Dunno how to display these
  two halfwords from a windows cmd.exe; sorry...

If you're on windows {testing this on windows 7 but I suspect is widespread on
recent releases} you want to dump all the registry entries {they are not numerous
and are all one-liners} in  ...Services\partmgr\Enum
   a)  in general you can do this with a command supplied already for windows;
     REG  {on my box is in c:\windows\system32\reg  }
  So do this;
                    <<continuing long line here>>partmgr\Enum
I get backHKEY_LOCAL_MACHINE\system\currentcontrolset\services\partmgr\enum
    0    REG_SZ    Root\LEGACY_PARTMGR\0000
    Count    REG_DWORD    0x3
    NextInstance    REG_DWORD    0x3
    1    REG_SZ    SCSI\Disk&Ven_ATA&Prod_ST31000524AS\4&20155ac6&0&000000
    2    REG_SZ    USBSTOR\Disk&Ven_&Prod_&Rev_PMAP\07032A9A9FF92284&0
That last 'file', named just  "2", is the entry for my thumb drive.  USBSTOR  is a bit generic;
then  Disk&Ven  string is empty,  Prod  is empty,   REV is "PMAP",
          then you see the serial number and the obligatory trailing &0  character pair.

  b) in particular if your winbox has  cygwin installed then even at cmd.exe you can use
the   ls    and   cat   commands to show what 'files' are in that 'folder' of the registry and
            dump their contents to standard output;  so either at a cmd.exe or a bash prompt do
  ls -lh  /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/
         <<continuing long line here>>partmgr/Enum
 to see something like 
total 0
-r--r----- 1 Administrators SYSTEM 25 Jul 30 19:57 0
-r--r----- 1 Administrators SYSTEM 56 Jul 30 19:57 1
-r--r----- 1 Administrators SYSTEM 52 Jul 30 19:57 2
-r--r----- 1 Administrators SYSTEM  4 Jul 30 19:57 Count
-r--r----- 1 Administrators SYSTEM  4 Jul 30 19:57 NextInstance
and to dump "file" 2 for example can do
 cat /proc/registry/HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/
         <<continuing long line here>>partmgr/Enum/2          to get back

  My install of cygwin does not include the  linux command  lsusb   but perhaps it is 
available out on the internet for cygwin, somewhere...  I just do not have much 
incentive to research that point given how easy it is to use the  /proc/registry
"filesystem"  to work around it...

7/31/2016 1:20:23 AM
comp.databases.pick 5449 articles. 2 followers. ttrroonniicc (5) is leader. Post Follow

0 Replies

Similar Articles

[PageSpeed] 16