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 variable in my batch file
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. ) )
1.4m articles
1.4m replys
5 comments
57.0k users