http://qs321.pair.com?node_id=361788


in reply to USB Drive Letter Assignment in Win32

Is there a particular reason you need it to be located at a set location? It may be easier if the program that needs to access the thumb dive polls the drive names of the attached drives and then connects to the correct drive. This would make the application more portable in system that may have multiple drives or network drives.

Not sure if this is for something just for your use or for distribution.

Good Luck.
  • Comment on Re: USB Drive Letter Assignment in Win32

Replies are listed 'Best First'.
Re^2: USB Drive Letter Assignment in Win32
by traveler (Parson) on Jun 06, 2004 at 22:16 UTC
    Actually, after long consideration, I suppose not. I could look for it every time, if it is not too long a process. I need the data on the drive available at the very start of the login process so if I could find it, it would be alright. Any idea how to find a thumb drive?

      Any idea how to find a thumb drive?

      You could try putting a file of certain name on the drive and search for that in the root of every drive. Else, you could just find the last valid drive letter, and you have some chance that it is the usb device. Or else you could just find the drive with the smallest capacity (excuding floppies), but that may fail to work later if usb devices get cheaper.

        Or create a description file for each drive in its root. And have your scripts at startup that need particular drives scan these files. Or have a first run script that updates an index file so your scripts just read the index to find a resource. This sounds familiar????

        "No matter where you go, there you are." BB
      Sorry for the late responce--

      Give the drive a Label "USBDrive" then...
      use Win32::AdminMisc; %Info = Win32::AdminMisc::GetVolume($drive); print "Drive label is $Info{Volume}\n";
      Cycle through all the attached drives and then you will be able to find the drive you are looking for.
      See the doc for complete info:

      http://www.roth.net/perl/adminmisc/
        I installed the ppd and then ran this code. Perl whined about no GetVolume and I could not find it either. I have version 2003.07.14

        Thanks!