The part where incrementation do no occur:
EndLocal & FOR /L %%i in (0, 1, 2) DO ( echo %%i - Do not increment???
REM Set "DeviceID[%%i]=%DeviceID[%%i]: =%"
REM Set "VolumeName[%%i]=%VolumeName[%%i]: =%"
)
Full code
Code: Select all
@Echo off
call :searchUSBdriveLetter
echo %DeviceID[]%
::echo "%USBdriveLetter%"
:: Set "installDevice=\\?\%USBdriveLetter%"
:: echo %installDevice% - device
pause
:searchUSBdriveLetter
setlocal enabledelayedexpansion
Set "USBdriveLetter="
Set /a "i=0"
For /f "tokens=1-9" %%a IN (
'wmic logicaldisk list brief'
) do (
Set "DeviceID=%%a"
Set "DriveType=%%b"
Set "VolumeName=%%e"
Set "ProviderName=%%d"
if !DriveType! Equ 2 if !ProviderName! gtr 0 Set /a "i=i+1"
if !DriveType! Equ 2 if !ProviderName! gtr 0 Set "DeviceID[!i!]=!DeviceID!"
if !DriveType! Equ 2 if !ProviderName! gtr 0 Set "VolumeName[!i!]=!VolumeName!"
)
Set "countedUSBdrives=%i%"
IF ["%USBdriveLetter%"]==[""] Set "USBdriveLetter=NoConnectedUSBdriveLetter"
EndLocal & FOR /L %%i in (0, 1, 2) DO ( echo %%i - Do not increment???
REM Set "DeviceID[%%i]=%DeviceID[%%i]: =%"
REM Set "VolumeName[%%i]=%VolumeName[%%i]: =%"
) & GOTO :Eof