Hello, am having some trouble with Windows batch variable expansion. Am trying to make a script that will make a list of all currently plugged in drives. I want to omit the system drive, since that one shows up as a blank letter. The following script can be copy+paisted directly into windows command line, you just have to turn on delayed variable expansion first, so I will paste both commands here:
SETLOCAL ENABLEDELAYEDEXPANSION
set mylist=& for /f "tokens=3 delims= " %A in ('echo list volume ^| diskpart ^| findstr /V "###" ^| findstr /V "System" ^| findstr "Volume"') do (set mylist=!mylist! %A:)
The script does not work right though, because when I tell the variable to echo, I get the variable name at the beginning of the output, aswell as the output printed twice.
C:\Users\UserName>echo %mylist%
!mylist! E: F: C: D: G: H: J: E: F: C: D: G: H: J:
Would be cool if somebody knows what's going on.