# Solved: WMIC Stump



## scrfix (May 3, 2009)

Damn,

Going off the other post that we spoke together on from the orther forum, I tried to utilize a FOR statment for the WMIC LOGICALDISK to be able to grab the letters from there.

I have attached the output of wmic logicaldisk>wmic.txt

The problem I am running into is that the tokens are not always exactly the same when you do the above command. Letter C is in token 2 whereas letter D is in token 1 and letter H is back to token 2. I would like it just to output the letter. I have tried delims, the FIND command, eol=. Is there a way to do this? Example please?


```
@echo on
set _ab=ABCDEFGHIJKLMNOPQRSTUVWXYZ
setlocal EnableDelayedExpansion

:_UsedDriveLetterCheck
FOR /F "tokens=2*" %%I IN ('WMIC LOGICALDISK ^| FIND /I ": "') DO CALL :_UsedDriveLetterCheckProcess %%I
GOTO _COMPLETED
 
:_UsedDriveLetterCheckProcess
FOR /F "tokens=1" %%I IN ("%_ab%") DO (set _ab=!_ab:%1=!)&GOTO :EOF
GOTO :EOF
 
:_COMPLETED
echo %_ab%
pause
```


----------



## Squashman (Apr 4, 2003)

wmic logicaldisk get deviceid


----------



## Squashman (Apr 4, 2003)

```
@echo off
set _ab=ABCDEFGHIJKLMNOPQRSTUVWXYZ
setlocal EnableDelayedExpansion

:_UsedDriveLetterCheck
FOR /F "skip=1 tokens=1 delims=:" %%I IN ('WMIC LOGICALDISK get deviceid') DO set _ab=!_ab:%%I=!

echo %_ab%
```
On my machine I have A C D E and F. So the output is this.

```
C:\Users\Squashman>disklist.bat
BGHIJKLMNOPQRSTUVWXYZ
```


----------



## scrfix (May 3, 2009)

Thanks. I had no idea I could do the "get deviceid".
Thanks for the example. Some times you cannot see the forest through the trees as in this case. I will using the call because I thought I needed to iterate through the string prior to removing the letters.


----------



## Squashman (Apr 4, 2003)

scrfix said:


> Thanks. I had no idea I could do the "get deviceid".
> Thanks for the example. Some times you cannot see the forest through the trees as in this case. I will using the call because I thought I needed to iterate through the string prior to removing the letters.


When you called that separate For Loop you were not iterating through the Alphabet. It was one big token of 26 letters. That is why I had said in a previous post to you that you didn't need the call and the second For Loop. Don't remember what thread I said that in but do remember telling you that.


----------

