How do I find out about the driver letter of a usb drive by script, given the DeviceID

Hi all,
I am wondering if it is possible by script to find out what the drive letter of a usb drive might be.
I have just inserted my USB stick into a socked and the operating system displays that the drive was recognized and that the drive letter is F:.
I already know, how USB devices can be listed by WMI script, but how do I extract the drive letter of a USB storage device.
The DeviceID is known, where do I find the drive letter given the DeviceID ?
Disk drive
DeviceID:
USBSTOR\DISK&VEN_SAMSUNG&PROD_YP-U2&REV_0100\4002FDCCE0E4D094&0
Service: disk
Status: OK
SystemName: MEINER
Caption: Samsung YP-U2 USB Device
All help is welcome

@echo off  
:: GetLetterOFmyUSBstick.cmd  
:: Bye Gastone Canali  
::DeviceID: USBSTOR\DISK&VEN_SAMSUNG&PROD_YP-U2&REV_0100\4002FDCCE0E4D094&0  
setlocal EnableDelayedExpansion  
set PNPDeviceID=4002FDCCE0E4D094 
set Q='wmic  diskdrive where "interfacetype="USB" and PNPDeviceID like "%%%PNPDeviceID%%%""    assoc /assocclass:Win32_DiskDriveToDiskPartition' 
echo %Q%  
for /f "tokens=2,3,4,5 delims=,= " %%a in (%Q%) do (  
  set hd=%%a %%b, %%c %%d  
  call :_LIST_LETTER !hd!)  
goto :_END  
:_LIST_LETTER  
(echo %1 |find  "Disk ") >nul|| goto :_EOF   
for /f "tokens=3 delims==" %%a in ('WMIC Path Win32_LogicalDiskToPartition  ^|find %1') do set TMP_letter=%%a  
set Part_letter=%TMP_letter:~1,2%   
echo %Part_letter% %1  
goto :_EOF  
:_END  
:_EOF  
' ' GetLetterOFmyUSBstick.vbs
strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")  
strPnPdevID = "USBSTOR\DISK&VEN_SAMSUNG&PROD_YP-U2&REV_0100\4002FDCCE0E4D094&0" 
strPnPdevID = Replace(strPnPdevID, "\", "\\")  
Set colDiskDrives = objWMIService.ExecQuery ("SELECT * FROM Win32_DiskDrive where PNPDeviceID like '"& strPnPdevID &"' ")  
For Each objDrive In colDiskDrives  
    Wscript.Echo "Physical Disk: " & objDrive.Caption & " -- " & objDrive.DeviceID   
    strDeviceID = Replace(objDrive.DeviceID, "\", "\\")  
    Set colPartitions = objWMIService.ExecQuery _  
        ("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _  
            strDeviceID & """} WHERE AssocClass = " & _  
                "Win32_DiskDriveToDiskPartition")  
    For Each objPartition In colPartitions  
        Wscript.Echo "Disk Partition: " & objPartition.DeviceID  
        Set colLogicalDisks = objWMIService.ExecQuery _  
            ("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _  
                objPartition.DeviceID & """} WHERE AssocClass = " & _  
                    "Win32_LogicalDiskToPartition")  
        For Each objLogicalDisk In colLogicalDisks  
            Wscript.Echo "Logical Disk: " & objLogicalDisk.DeviceID  
        Next 
        Wscript.Echo  
    Next 
    Wscript.Echo  
Next 

Similar Messages

  • How do you find out about Kernel panics?

    Can anyone please explain to me how does one find out about Kernel panics, where to look etc? Thanks and regards

    When the operating system kernel, one of the most basic, foundational levels of the Mac OS X operating sytem, detects some kind of exceptional condition or internal corruption or when the hardware sends it a signal of some grave error, which can be a bug in the system software or a driver or can be a hardware problem and the situation is not one that can be dealt with and continuing operation is impossible, then the kernel "panics." It does it's best to shut down gracefully, but it's an abortive termination of all system activity, after which a reboot usually takes place (though you're notified and must intervene before that happens).
    It is a serious error and should not occur, but computer technology, both hardware and software, being what they are, there's no way to absolutely guarantee they won't happen. Unix-based systems such as Mac OS X have pretty good reliability, especially since Apple controls both the hardware and software. Still, 3rd-party software can be incorporated into a system, and Apple does not control or certify that code, so there's ample opportunity for poorly written add-ons (especially hardware drivers) to cause problems.
    Randall Schulz

  • How do I find out about apps for my business

    How do I find out about potential apps that exist but that I don't know of yet

    Hey,
    What I would recommend doing is contacting the local Apple Store in your area. All Apple Retail Stores have specialized business teams that hold free workshops on using the iPad for business and have lots of knowledge about business applications/uses. Give your local store a call and ask for the business team!
    Hope this helps =)
    rizz

  • How do I find out about disk usage ie how much space I have used

    how do I find out about the startup disk, and how much space I have on the computer?

    Try http://www.omnigroup.com/products/omnidisksweeper/
    Alaln

  • How do you find out about new VoD videos

    Quick question for FiOS TV users - how do you (personally) find out about new on-demand videos?
    Do you rely on the Spotlight email, or the trailers playing in the VoD store-front, or mail inserts etc? Keen to hear what everyone thinks works best!
    Thanks,
    Rich

    Here is one suggestion for you.
    http://www22.verizon.com/residential/fiostv/vod/vod.htm
    Joe D
    Verizon Telecom
    Fiber Solution Center
    Notice: Content posted by Verizon employees is meant to be informational and does not supercede or change the Verizon Forums User Guidelines or Terms or Service, or your Customer Agreement Terms and Conditions or Plan.Follow us on Twitter™!

  • How do I find out about iPhoto sales and promotions?

    I randomly happened to print a book in iPhoto about a month ago, and it told me that there was free shipping due to the Mother's Day holiday.  How can I find out when these sales or promotions are happening so that I could do this on purpose?  (You'd think that it would be easy to find a way to sign up for spam like this, but I've looked for an hour and can't find any indication that Apple wants me to know about their sales.)

    Haven't seen any such promotions in years and there is no such email address ever mentioned here. There is a link to contact Apple at the bottom of every page, on the right, perhaps someone there can help.

  • How do I find out if an ipod is registered so I can return it to the owner?

    How do I find out if an ipod is registered so I can return it to its owner?

    Call Apple Customer Relations - 1-800-767-2775.  Once you give them the serial #, they will check to see if the iPod Nano was ever registered, contact the owner to let them know their iPod Nano was found.  The owner will contact you if you gave CR your name & phone#.

  • How do I find out about my warrenty on here because I cannot find my paper work?

    I just dropped my phone and my whole screen cracked and I need to find out how I look up my warrenty so I can know what I have to do or pay for a new phone?

        Sorry to hear about your phone Rebeccashanks1. Lost/Stolen/Damaged equipment is not covered under warranty. However, if you have insurance you can process a claim and receive a replacement. Are you aware if you have insurance? If so, please process your claim and review your deductible here http://bit.ly/07CrqPK or call 888-881-2622. If you are unaware you can view your feature online here http://bit.ly/xB4iTc or I can also clarify. If you need additional assistance please send me a DM with your mobile number. Thank you.
    Tominque B.
    Please follow us on Twitter @VZWSupport

  • How can I find out about an order?

    Hi I ordered a tablet on 06.08.15.Had an email saying order had been referred.I haven't heard anything since and I cannot ring customer services as I have no phone at the minute.Just worrying in case they have been trying to phone me about my order. What can I do?

    I know that. My post was to find out if there was another way of making contact as I CANNOT phone them.

  • How can I find out about development of Thunderbird?

    I can't find any information on development of Thunderbird.
    Links on the Thunderbird homepage only take me to the general "Mozilla" pages instead of any Thunderbird-specific pages. https://www.mozilla.org/en-US/thunderbird/

    Thunderbird is a community project and while Mozilla's involvement is significantly reduced, that does not get the code base out on it's own. Thunderbird and SeaMonkey are basically the comm central folder in the Mozilla code base. Hence everything linking to Mozilla. Thunderbird shared the Geko layout engine with Firefox and to all intents and purposes that is almost indistinguishable from Firefox. The result is Thunderbird developers find themselves working on core to fix Thunderbird bugs, even though it is technically part of Firefox.
    Everything is controlled through bugzilla. enhancements, faults, poor usability and design. You do not need to do more that assign your self a bug and start coding. Although the involvement of the module owner or a peer helps get patches accepted. https://wiki.mozilla.org/Modules/Thunderbird
    Bugzilla is used to extract details of bugs fixed (including enhancement) for the documentation of release notes. Because flagging bug for inclusion in release notes is manual there are always those the just appear without a release notes.
    Talking or communicating with other developers appears to still be mostly IRC. (Global means Global at Mozilla with people in many countries collaborating)
    This wiki page https://wiki.mozilla.org/IRC after lots of instructions does tell you what channels are for what in Mozilla IRC.
    Links to mercurial, are on this page. https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Source_Code/Mercurial
    Downloadable source here https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Source_Code/Downloading_Source_Archives
    Is there a specific area you were looking at? perhaps I can point you to someone.

  • How do I find out about my cd sales and weekly trends ??

    I have 2 cds on ITunes and have had millions of plays on Number One Music with the direct link to Itunes,  but no reports from Itunes about sales ????

    If you are an artist, then you should have contact information for someone at iTunes that handled getting your music on iTunes.
    No one here can assist as we're just users.
    You could try the "Contact Us" link at the bottom.

  • How do i find out about my account getting messed with ?

    Facebook, pictures,information, password...
    Theu used my phone # to get into my account..

    If there is a problem with the security of your Facebook account, you should check with Facebook on whether they can trace the access to a particular device. This isn't something you can determine on your own.
    https://www.facebook.com/help/131719720300233/ (Help on Hacked Accounts)

  • HT5622 I think my granddaughter bought a $3.99 app after I put the password in for a free app.  How can I find out what she purchased?  Can I get credit for it?  I just got an email from my credit card confirming the purchase.

    I think my granddaughter bought a $3.99 app after I put the password in for a free app.  I just got an email from my credit card confirming the purchase.  How can I find out what she purchased?  Can I get credit for it? 

    The password is good for 15 minutes to make purchases. You should receive a receipt in 24 to 48 hours for the purchases. There is a link to Report an issue. You could use that to start a conversation with iTunes Support about a refund.
    Apple considers all sales final. But has been known to offer a one time refund. So the question is, do you want to use your one time refund on this purchase or one more expensive in the future?

  • I have recently got a new replacement iPhone 4.  since I got this I have found that my data allowance is getting used up during the night while my phone is charging on the bedside table.  How an I find out what is causing this and stop it happening

    I have recently got a new replacement iPhone 4.  Since I got this I have found that my data allowance is getting used up during the night while my phone is charging on the bedside table.  How an I find out what is causing this and stop it happening?  Some nights the usage is 150 meg!

    You can not access the backup directly.
    Did you restore your replacement from this backup?
    If so then you already have everything in the backup on your device.
    If not, you can wipe the device and restore from this backup:
    Settings > General > Reset > Erase All Content & Settings
    What is it you are worried about losing that isn't already on your current device?

  • .How do I find out what Version (generation) of Ipod touch I have, as I want to know if I can download IOS 5 onto it? It was a gift so I only know the model and serial numbers but not the type

    Hi, can anyone help me out with this question?
    How can I find out which version of Ipod touch I have. I only have the model and serial numbers as it was a gift, but I would like to download IOS 5 if it is compatible?
    Very frustrated Ipod user, any advice would be much appreciated.
    Lynda.

    I had the same problem because there are so many iPod models.  There is a great article in Wikileaks that explains it all and also has pictures.  I'm confident this answer your question.

Maybe you are looking for

  • Scheduling Agreement invoice verification

    Hi friends, This is the issue I'm facing with my client Buyer created the scheduling agreement and delivery lines. item cost 2$ per piece user received the material against scheduling agreement line item. system generated the material document. Due t

  • How to calculate overwrighting commission to the third party

    hi, sap gurus, here is the scenario: my sold to party is different and ship to, bill to and pyr is different. but the order will be on sold to - ie on third party. and the rest are the same ie - delivery, billing, payment is from the party to whom we

  • How to specify the target for a command button action?

    Hi can anybody explain how to achieve the target feature, i mean i need to display the result of the action in a different window after clicking on the button. Is there anyway to achieve this? I want to click the button using Javascript.(using button

  • Fetch GLPCA-SPRCTR instead of csks-PRCTR - Urgent

    Hi All, i have a report which dispalys a column profit center (CSKS-PRCTR). My functional wants to replace this field (CSKS-PRCTR) with GLPCA-SPRCTR. I tried with various option but not successful. Any help would be highly appreciated. Thanks, Senthi

  • SCVMM service crash when trying to connect with admin console

    Hello, i'm using SCVMM for a while but from the beginning of the year (2010), the vmm service crash when i try to connect with the vmm admin consol . More in detail: vmm service is running on serverA. (vmmservice 2.0.3444.0) Admin console is running