Find USB Drive letter

前端 未结 5 456
星月不相逢
星月不相逢 2020-12-18 16:57

I need to get the drive letter of the usb pen drive.the command CHDIR >drive.txt gives me the drive letter L:.How do I read/get this info \"L:\" without quotes into a variab

5条回答
  •  一个人的身影
    2020-12-18 17:32

    Here's how to get a USB drive letter from any drive.

    @echo off
    
    for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,drivetype 
    
    2^>NUL`) do (
    
    if %%l equ 2 (
    echo %%i is a USB drive.
    )
    )
    

提交回复
热议问题