I want to write a batch file such that when I run it in cmd, it sets a new variable equal to the drive letter of my usb flash drive (if, of course, it's the only storage device of that type). Assume ,for now, that I don't care whether it has colon appended to it or not.
This is what I tried while having a functioning Integral USB connected to my laptop:
@echo off for /F "tokens=1,2,3,4,5" %%A IN ('wmic logicaldisk get description') DO ( if %%A=="Removable Disk" ( @echo wmic logicaldisk get caption )else ( @echo no luck! ) )
This was the output:
no luck! no luck! no luck! no luck! no luck! no luck!
Can anyone point out some of the obvious errors in the script?
Also this is the result of the wmic commands being ran from cmd:
C:\Users\Dziugas\Desktop>wmic logicaldisk get caption,description Caption Description C: Local Fixed Disk D: CD-ROM Disc E: CD-ROM Disc F: Removable Disk