Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

DOS/Other DOS/Other
Search Search
Search for:
Tech Support Guy > > >

Solved: WMIC Stump


(!)

scrfix's Avatar
scrfix scrfix is offline
Computer Specs
Member with 337 posts.
THREAD STARTER
 
Join Date: May 2009
Experience: Computer Repair Expert
09-Jul-2011, 03:18 PM #1
Solved: WMIC Stump
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?

Code:
@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
Attached Files
File Type: txt wmic.txt (5.0 KB, 59 views)
Squashman's Avatar
Trusted Advisor with 19,643 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
10-Jul-2011, 12:28 AM #2
wmic logicaldisk get deviceid
Squashman's Avatar
Trusted Advisor with 19,643 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
10-Jul-2011, 01:40 AM #3
Code:
@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.
Code:
C:\Users\Squashman>disklist.bat
BGHIJKLMNOPQRSTUVWXYZ
scrfix's Avatar
scrfix scrfix is offline
Computer Specs
Member with 337 posts.
THREAD STARTER
 
Join Date: May 2009
Experience: Computer Repair Expert
10-Jul-2011, 11:35 AM #4
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's Avatar
Trusted Advisor with 19,643 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
11-Jul-2011, 11:45 AM #5
Quote:
Originally Posted by scrfix View Post
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.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
WELCOME TO TECH SUPPORT GUY!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑